feat(websub): wire real-time push notifications on email ingest

Pass ExecutionContext through the email processing chain so notifySubscribers
is called via ctx.waitUntil after a new email is stored.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
This commit is contained in:
Julien HerrandClaude Sonnet 4.6 committed 2026-05-21 23:46:50 +02:00
1 parent 6d221a07dd
commit d0764ddd8e
4 files changed
+10 -2

No files matched your search

+5
View File
@@ -6,6 +6,7 @@ import {
FeedConfig,
FeedMetadata,
} from "../types";
import { notifySubscribers } from "../utils/websub";
export interface RawAttachment {
filename: string;
@@ -73,6 +74,7 @@ async function uploadAttachments(
export async function processEmail(
input: ProcessEmailInput,
env: Env,
ctx?: ExecutionContext,
): Promise<Response> {
const feedId = EmailParser.extractFeedId(input.toAddress);
if (!feedId) {
@@ -182,5 +184,8 @@ export async function processEmail(
]);
console.log(`Successfully processed email for feed ${feedId}`);
if (ctx) {
ctx.waitUntil(notifySubscribers(feedId, env));
}
return new Response("Email processed successfully", { status: 200 });
}