feat(mail): in-app attachments on internal mail + surface media parts in thread reads
- MailInternalDto accepts attachments[]; deposit() stores each as a media part (image/video→MEDIA_REF, audio→VOICE_REF, else FILE_REF) - ingest now persists part sizeBytes; contract + DTO carry it - threads.getMessages returns mimeType + sizeBytes so mail readers can render inline images / file chips - test: internal mail stores an image attachment as a MEDIA_REF part Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -66,6 +66,20 @@ describe('MailService.postInternal', () => {
|
||||
expect(aliceThreads.map((t) => t.threadId)).toContain(res.threadId);
|
||||
});
|
||||
|
||||
it('stores an in-app attachment as a media part alongside the body', async () => {
|
||||
const res = await mail().postInternal(alice, {
|
||||
source: inline, recipientUserId: 'bob', idempotencyKey: 'int:att',
|
||||
attachments: [{ filename: 'roof.png', contentRef: 'scope/roof.png', mimeType: 'image/png', sizeBytes: 2048 }],
|
||||
});
|
||||
const interaction = await prisma.iiosInteraction.findUniqueOrThrow({ where: { id: res.interactionId }, include: { parts: true } });
|
||||
const file = interaction.parts.find((p) => p.contentRef);
|
||||
expect(file).toBeDefined();
|
||||
expect(file!.kind).toBe('MEDIA_REF'); // image/* → MEDIA_REF
|
||||
expect(file!.contentRef).toBe('scope/roof.png');
|
||||
expect(file!.mimeType).toBe('image/png');
|
||||
expect(file!.sizeBytes != null ? Number(file!.sizeBytes) : null).toBe(2048);
|
||||
});
|
||||
|
||||
it('is idempotent per key — a replay reuses the same thread, no duplicate interaction', async () => {
|
||||
const a = await mail().postInternal(alice, { source: inline, recipientUserId: 'bob', idempotencyKey: 'int:dup' });
|
||||
const b = await mail().postInternal(alice, { source: inline, recipientUserId: 'bob', idempotencyKey: 'int:dup' });
|
||||
|
||||
Reference in New Issue
Block a user