forked from bchanot/claude
Always-on rules/secure-by-default.md: hosting, a11y, Supabase RLS, SMS/email consent, cloud functions, API hygiene incl. password storage. Stdlib scanner (FAIL/WARN/MANUAL) + skill, 89-check suite, auditor gate wiring, profiles, routing row (plus Explore rows confirmed through the router dialog).
23 lines
649 B
TypeScript
23 lines
649 B
TypeScript
import { Resend } from "npm:resend";
|
|
|
|
const resend = new Resend(Deno.env.get("RESEND_API_KEY"));
|
|
|
|
Deno.serve(async (request) => {
|
|
const user = await getUser(request);
|
|
const contact = await loadContact(user.id);
|
|
if (!contact.consent_at || contact.unsubscribed_at) {
|
|
return new Response("skipped");
|
|
}
|
|
const link = unsubscribeUrl(contact.id);
|
|
await resend.emails.send({
|
|
to: contact.email,
|
|
subject: "News",
|
|
html: `<p>Hello</p><a href="${link}">Unsubscribe</a>`,
|
|
headers: {
|
|
"List-Unsubscribe": `<${link}>`,
|
|
"List-Unsubscribe-Post": "List-Unsubscribe=One-Click",
|
|
},
|
|
});
|
|
return new Response("sent");
|
|
});
|