mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-06-16 17:55:26 -04:00
Keep Cc recipients in reply-all
* fix: populate window._myEmailAddress from the active email account * fix: keep Cc recipients in reply-all when own address is empty or unknown * test: cover reply-all recipient building (issue #360)
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
// static/js/emailLibrary/replyRecipients.js
|
||||
//
|
||||
// Pure helpers for building reply-all recipient lists. No DOM, no fetch,
|
||||
// no shared state — safe to import anywhere and to unit-test under node.
|
||||
|
||||
// Extract the bare email from "Name <email@x>" or a plain "email@x".
|
||||
export function extractEmail(addr) {
|
||||
const m = (addr || '').match(/<([^>]+)>/);
|
||||
return (m ? m[1] : (addr || '')).trim().toLowerCase();
|
||||
}
|
||||
|
||||
// Reply-all CC = everyone on the original To + Cc, minus ourselves, with the
|
||||
// original "Name <email>" form preserved.
|
||||
//
|
||||
// `myAddress` empty/unknown ⇒ no exclusion. Comparing by exact extracted email
|
||||
// (not a substring `includes`) is what fixes issue #360: an empty self address
|
||||
// made `"...".includes("")` true for every recipient, so reply-all dropped the
|
||||
// entire Cc list and kept only the original sender.
|
||||
export function buildReplyAllCc(data, myAddress) {
|
||||
const me = (myAddress || '').toLowerCase();
|
||||
const split = (s) => (s || '').split(',').map((x) => x.trim()).filter(Boolean);
|
||||
return [...split(data && data.to), ...split(data && data.cc)]
|
||||
.filter((addr) => !me || extractEmail(addr) !== me)
|
||||
.join(', ');
|
||||
}
|
||||
Reference in New Issue
Block a user