Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: match Teams recipient suggestions by exact email to prevent misdelivery

[._.]/ Adam Eivya4683d9b9715
diff --git a/server/lib/messageBrowserCompose.js b/server/lib/messageBrowserCompose.js
index 9742023c18..e243869dc6 100644
--- a/server/lib/messageBrowserCompose.js
+++ b/server/lib/messageBrowserCompose.js
@@ -315,12 +315,15 @@ async function openComposeInPage(args, h, readRow) {
h.typeInto(input, address);
const option = await h.waitFor(() => {
const hits = [...document.querySelectorAll(sels.recipientSuggestion)]
- .filter(el => h.visible(el) && h.labelOf(el).toLowerCase().includes(address));
+ .filter(el => {
+ const emails = h.emailsIn(el);
+ return h.visible(el) && emails.length === 1 && emails[0] === address;
+ });
return hits.length === 1 ? hits[0] : null;
}, 6000);
if (!option) return { code: 'RECIPIENT_UNRESOLVED' };
option.click();
- resolved.push(address);
+ resolved.push(...h.emailsIn(option));
await h.sleep(300);
}
const box = await h.waitFor(() => h.only(document, sels.composeBox));
diff --git a/server/lib/messageBrowserCompose.test.js b/server/lib/messageBrowserCompose.test.js
index 706c367c8f..69045b9b82 100644
--- a/server/lib/messageBrowserCompose.test.js
+++ b/server/lib/messageBrowserCompose.test.js
@@ -118,3 +118,45 @@ describe('buildComposePhaseScript', () => {
expect(() => buildComposePhaseScript('send-now', args)).toThrow(/Unknown compose phase/);
});
});
+
+// Execute the actual recipient-picker script: a transport stub returning the
+// requested address cannot catch a suggestion for a different mailbox.
+describe('Teams recipient selection in the provider page', () => {
+ it.each([
+ ['Ann Example [email protected]', true],
+ ['Joann Example [email protected]', false],
+ ['Ann Example [email protected] [email protected]', false],
+ ])('selects only an exact, unambiguous address from %s', async (suggestion, accepted) => {
+ let selected = false;
+ let now = 0;
+ const element = (innerText = '') => ({
+ innerText, isConnected: true, disabled: false,
+ getClientRects: () => [{}], getAttribute: () => null,
+ querySelectorAll: () => [], focus() {}, click() {}, setAttribute() {},
+ });
+ const input = element();
+ const box = element();
+ const option = { ...element(suggestion), click: () => { selected = true; } };
+ const sels = COMPOSE_SELECTOR_DEFAULTS.teams;
+ const matches = {
+ [sels.newChat]: [element()], [sels.recipientInput]: [input],
+ [sels.recipientSuggestion]: [option], [sels.composeBox]: [box],
+ };
+ const document = {
+ execCommand() {},
+ querySelector: selector => selector === sels.composeBox ? box : null,
+ querySelectorAll: selector => matches[selector] || [],
+ };
+ const result = await vm.runInNewContext(buildComposePhaseScript('open', {
+ provider: 'teams', sels, token: 'attempt-1', to: ['[email protected]'],
+ }), { document, Date: { now: () => { now += 1000; return now; } }, setTimeout: callback => { callback(); } });
+ expect(selected).toBe(accepted);
+ if (accepted) {
+ expect(result.ok).toBe(true);
+ expect(recipientsMatch({ to: ['[email protected]'], cc: [] }, { to: result.resolved, cc: [] })).toBe(true);
+ } else {
+ expect(result.code).toBe('RECIPIENT_UNRESOLVED');
+ expect(result.resolved).toBeUndefined();
+ }
+ });
+});