feat(ingest): detect and mark confirmation emails

This commit is contained in:
Julien Herr
2026-05-25 09:04:36 +02:00
parent 36d58ade48
commit c4d591b962
2 changed files with 67 additions and 1 deletions
+13 -1
View File
@@ -5,7 +5,12 @@ import { dispatchFeedEvents } from "../application/feed-events";
import { extractEmailDomain } from "../infrastructure/favicon-fetcher";
import { parseOneClickUnsubscribe } from "../infrastructure/unsubscribe";
import { getAttachmentBucket } from "../infrastructure/attachments";
import { extractInlineCids } from "../infrastructure/html-processor";
import {
extractInlineCids,
extractLinks,
htmlToText,
} from "../infrastructure/html-processor";
import { detectConfirmation } from "../domain/confirmation";
import { attachmentIdsForCleanup } from "./feed-cleanup";
import { FeedRepository } from "../infrastructure/feed-repository";
import { BackgroundScheduler } from "../infrastructure/worker";
@@ -182,6 +187,12 @@ async function storeEmail(
return false; // signal: skipped (not stored)
}
const confirmation = detectConfirmation({
subject: input.subject,
text: htmlToText(input.content),
links: extractLinks(input.content),
});
const attachmentBucket = getAttachmentBucket(env);
const inlineCids = extractInlineCids(input.content);
const storedAttachments: AttachmentData[] =
@@ -218,6 +229,7 @@ async function storeEmail(
...(inlineIds.length > 0 ? { inlineAttachmentIds: inlineIds } : {}),
...(messageId ? { messageId } : {}),
dedupHash,
...(confirmation ? { confirmation: { links: confirmation.links } } : {}),
};
// Track the latest sender's domain (feed icon) and capture the RFC 8058