feat(mail): tag mail threads source=crm-mail (list separately from chat)
ingest() puts metadata on the interaction, not the thread, and listThreads filters THREAD metadata — so MailService now tags the thread directly after deposit (source=crm-mail). Lets the CRM list mail threads apart from Messenger chat (source=crm-messenger). 7 tests. NOTE: requires an IIOS redeploy. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -25,7 +25,7 @@ function mail(): MailService {
|
||||
const ingest = new IngestService(asService, makeFakePorts(), actors);
|
||||
const outbound = new OutboundService(asService, new CapabilityBroker(makeFakePorts(), new CapabilityProviderRegistry()), new IdempotencyService(asService));
|
||||
const sender = new TemplatedSender(templates, outbound, makeFakePorts());
|
||||
return new MailService(templates, ingest, sender, actors);
|
||||
return new MailService(templates, ingest, sender, actors, asService);
|
||||
}
|
||||
const messages = () => new MessageService(asService, makeFakePorts(), actors);
|
||||
|
||||
@@ -56,6 +56,7 @@ describe('MailService.postInternal', () => {
|
||||
|
||||
const thread = await prisma.iiosThread.findUniqueOrThrow({ where: { id: res.threadId } });
|
||||
expect(thread.subject).toBe('Welcome Dana');
|
||||
expect((thread.metadata as { source?: string } | null)?.source).toBe('crm-mail'); // lists separately from chat
|
||||
|
||||
// The load-bearing assertion: the RECIPIENT can see the thread in their inbox.
|
||||
const bobThreads = await messages().listThreads(bob);
|
||||
|
||||
Reference in New Issue
Block a user