Files
kill-the-news/src/routes/inbound.ts
T
Julien HerrandClaude Sonnet 4.6 d0764ddd8e 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]>
2026-05-21 23:46:50 +02:00

23 lines
734 B
TypeScript

import { Context } from "hono";
import { Env } from "../types";
import { ForwardEmailPayload, handleForwardEmail } from "../lib/forwardemail";
export async function handle(c: Context): Promise<Response> {
try {
const env = c.env as unknown as Env;
const payload: ForwardEmailPayload = await c.req.json();
console.log("Received email:", {
to: payload.recipients?.[0],
from: payload.from?.text || "Unknown",
subject: payload.subject,
contentType: payload.html ? "HTML" : "Text",
});
return handleForwardEmail(payload, env, c.executionCtx);
} catch (error) {
console.error("Error processing email:", error);
return new Response("Error processing email", { status: 500 });
}
}