Creating Plot Twists
    Preparing search index...

    Function resolveOutboundReplyRecipients

    • Compute the To/Cc/Bcc lists for an outbound reply, shared by every sharingModel: "message" (email-style) connector so recipient resolution lives in ONE tested place instead of being re-implemented — and re-misimplemented — per connector.

      Three cases, in priority order:

      1. Platform-resolved recipients (recipients non-null): the note carried a curated recipient set and the runtime resolved it to addresses + roles, with the acting user's own identities already removed. Authoritative. This is the only case that can carry a display name — it comes from the resolved contact — so connectors relying on the other cases get name: null.
      2. Access-contact fallback (recipients null, accessContactEmails non-null): header participants are narrowed to that set; curated addresses not on the message are folded into To. Self is excluded via selfEmails.
      3. Reply-all (recipients null, accessContactEmails null): reply to the original participants (From ∪ To → To, Cc → Cc), minus self.

      Self-reply fallback: a self-email thread — a message you sent to your own or another linked address — otherwise resolves to no recipients, because every original participant is you and each case above removes self. When the result is empty AND the original message had no non-self To/Cc participant (i.e. this is a genuine self-thread, not a mixed thread narrowed to self) AND every original sender is self, the reply is addressed back to the original sender (headerFrom) so it stays deliverable. The connector still sends as its own mailbox — for the copy you received in, that mailbox is the original recipient.

      Parameters

      • args: {
            recipients: ResolvedRecipient[] | null;
            accessContactEmails: Set<string> | null;
            headerTo: string[];
            headerCc: string[];
            selfEmails: Set<string>;
            headerFrom?: string[];
            defaultRole?: Role;
        }

      Returns ReplyRecipients