refactor(app): derive native-feed base from EmailAddress.siteBaseUrl

Delete the `iconBase` local helper (which mishandled display-name form
like `Name <a@b.com>`) and replace it with `EmailAddress.parse(input.from)
?.siteBaseUrl()` — the domain-layer VO that already handles bare and
display-name addresses correctly.  Adds TEST C to lock the
display-name + relative-href absolutization fix.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Julien Herr
2026-05-25 17:25:52 +02:00
parent 5362d478e3
commit 6236274ce8
2 changed files with 29 additions and 8 deletions
+5 -8
View File
@@ -1,4 +1,5 @@
import { MailboxId } from "../domain/value-objects/mailbox-id";
import { EmailAddress } from "../domain/value-objects/email-address";
import { AttachmentData, EmailMetadata, Env } from "../types";
import { bumpCounters } from "../application/stats";
import { dispatchFeedEvents } from "../application/feed-events";
@@ -20,13 +21,6 @@ import { Feed } from "../domain/feed.aggregate";
import { logger } from "../infrastructure/logger";
import { FEED_MAX_BYTES } from "../config/constants";
// Best-effort site base for absolutizing a sender's relative feed link.
function iconBase(from: string): string {
const at = from.lastIndexOf("@");
const domain = at >= 0 ? from.slice(at + 1).trim() : "";
return domain ? `https://${domain}` : "";
}
export interface RawAttachment {
filename: string;
contentType: string;
@@ -203,7 +197,10 @@ async function storeEmail(
});
const nativeFeedList = detectNativeFeeds(
extractFeedLinks(input.content, iconBase(input.from)),
extractFeedLinks(
input.content,
EmailAddress.parse(input.from)?.siteBaseUrl() ?? "",
),
);
const attachmentBucket = getAttachmentBucket(env);