feat: decouple read FeedId from inbound MailboxId
Separate the two feed identities so the public read URL never reveals the inbound address and vice-versa: - FeedId becomes an opaque high-entropy token (read id + KV key); MailboxId (noun.noun.NN) owns the inbound address and the untrusted-input boundary via MailboxId.parse. They map only through the inbound:<mailbox> secondary index, resolved solely at reception. - inbound index lifecycle is owned by FeedRepository: written by save/saveConfig, dropped by removeFromList(Bulk) — symmetric, never mirrored by hand (removes the manual delete in feed-service + the cron loop, and a silent empty-catch). - Feed.mailboxId exposes a MailboxId VO (symmetry with Feed.id); the mailbox@domain shape lives on MailboxId.emailAddress(domain). - Distinguish mailbox_unknown (no feed claims the address) from feed_not_found (dangling index) for observability; both forwardable, both 404. - Drop the redundant EmailParser.extractMailbox pass-through so MailboxId.parse is the single parse boundary. Docs (README/INSTALL/CLAUDE.md/landing) and tests updated; 439 tests green, tsc clean, build dry-run OK. Co-Authored-By: Claude Opus 4.7 <[email protected]>
This commit is contained in:
1 parent
f7f10779bc
commit
1a4a479190
43 files changed
+649
-149
No files matched your search
@@ -1,8 +1,15 @@
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { createMockEnv } from "../test/setup";
|
||||
import { createFeedRecord, editFeed } from "./feed-service";
|
||||
import {
|
||||
createFeedRecord,
|
||||
editFeed,
|
||||
deleteFeedRecord,
|
||||
deleteFeedFastDetailed,
|
||||
} from "./feed-service";
|
||||
import { getCounters } from "./stats";
|
||||
import { FeedRepository } from "../infrastructure/feed-repository";
|
||||
import { FeedId } from "../domain/value-objects/feed-id";
|
||||
import { MailboxId } from "../domain/value-objects/mailbox-id";
|
||||
import type { Env } from "../types";
|
||||
|
||||
const mkEnv = (overrides: Partial<Env> = {}) =>
|
||||
@@ -54,6 +61,40 @@ describe("createFeedRecord — TTL policy", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("deleting a feed drops its inbound mailbox index", () => {
|
||||
it("deleteFeedRecord removes the inbound index so the address stops resolving", async () => {
|
||||
const env = mkEnv();
|
||||
const { feedId, mailboxId } = await createFeedRecord(env, { ...baseInput });
|
||||
const repo = FeedRepository.from(env);
|
||||
|
||||
// Sanity: the address resolves to the feed before deletion.
|
||||
expect(
|
||||
(await repo.resolveInbound(MailboxId.unchecked(mailboxId)))?.value,
|
||||
).toBe(feedId);
|
||||
|
||||
await deleteFeedRecord(env, FeedId.unchecked(feedId), () => {});
|
||||
|
||||
expect(
|
||||
await repo.resolveInbound(MailboxId.unchecked(mailboxId)),
|
||||
).toBeNull();
|
||||
});
|
||||
|
||||
it("the bulk path (deleteFeedFastDetailed + removeFromListBulk) clears the inbound index", async () => {
|
||||
const env = mkEnv();
|
||||
const { feedId, mailboxId } = await createFeedRecord(env, { ...baseInput });
|
||||
const repo = FeedRepository.from(env);
|
||||
|
||||
// The bulk admin path drops config/metadata, then removes from the list —
|
||||
// the latter is what clears the inbound index (symmetric with save()).
|
||||
await deleteFeedFastDetailed(env.EMAIL_STORAGE, FeedId.unchecked(feedId));
|
||||
await repo.removeFromListBulk([feedId]);
|
||||
|
||||
expect(
|
||||
await repo.resolveInbound(MailboxId.unchecked(mailboxId)),
|
||||
).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe("editFeed — TTL policy", () => {
|
||||
it("recomputes expiry from the server override on edit", async () => {
|
||||
const env = mkEnv({ FEED_TTL_HOURS: "1" });
|
||||
|
||||
Reference in new issue
Block a user