Skip to content

Post a notice to Slack or Discord when someone joins a list - #36

Open
frahlg wants to merge 1 commit into
mainfrom
web/signup-notices
Open

frahlg wants to merge 1 commit into
mainfrom
web/signup-notices

Conversation

@frahlg

@frahlg frahlg commented Oct 30, 2026

Copy link
Copy Markdown
Member

Problem

Fredrik wants to hear about every newsletter and FTW box waitlist sign-up without querying D1 by hand.

What changes

  • A new address on either list posts one line to the incoming webhook in the SIGNUP_WEBHOOK_URL secret, for example: New sign-up: FTW box waitlist (SE) · Waitlist 12 · Newsletter 40.
  • The notice never includes the address. Addresses stay in D1, as the privacy notice says, so the notice needs no change.
  • Slack reads text and Discord reads content, and the worker sends both, so a webhook URL of either kind works.
  • The insert now tells a new address from a repeat. A repeat updates country and consent and sends nothing.
  • The notice runs after the answer, through waitUntil. A failing webhook is logged and never reaches the visitor.
  • Without the secret, nothing is sent.
  • The README says where to set the secret and how to read the lists with cf d1 query.

To turn it on

  1. Create an incoming webhook in a private Slack or Discord channel.
  2. In Cloudflare, add it to the Pages project ftw under Settings → Variables and Secrets, as a secret named SIGNUP_WEBHOOK_URL, for Production.
  3. It applies from the next deployment. Merging this PR is one.

Evidence

  • node --test tests/*.test.mjs: 36 passed, 0 failed.
  • New tests cover:
    • one notice per new address, with the expected text and both fields, and no @ anywhere in it
    • no notice on a repeat, while the row still updates
    • a failing webhook still stores the row and answers ok
    • nothing sent without the secret
  • Not checked: a real Slack or Discord webhook.

🤖 Generated with Claude Code

A new address on the newsletter or the FTW box waitlist now posts one
line to the incoming webhook in the SIGNUP_WEBHOOK_URL secret: the list,
the country and both totals. The address itself stays in D1, so the
privacy notice holds. Slack reads the text field and Discord reads
content, so one webhook URL of either kind works.

The insert now tells a new address from a repeat: a repeat updates
country and consent and sends nothing. The notice runs after the
answer through waitUntil, and a failing webhook is logged, never shown
to the visitor. Without the secret nothing is sent.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Deploying ftw with  Cloudflare Pages  Cloudflare Pages

Latest commit: 694ec54
Status: ✅  Deploy successful!
Preview URL: https://9cc00e7a.ftw-613.pages.dev
Branch Preview URL: https://web-signup-notices.ftw-613.pages.dev

View logs

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-30T10:00:08.621438Z 694ec54 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@miravoss26 miravoss26 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Posts a one-line notice to a Slack/Discord webhook (SIGNUP_WEBHOOK_URL) when a new address joins a list. CI green.

Looks good. Security screen:

  • The notice carries list, country and totals only. Test asserts no @ in the payload, so addresses stay in D1 as the privacy notice says.
  • New outbound host is whatever the secret points to, set by the operator, not from request input. No SSRF surface.
  • Webhook runs via ctx.waitUntil and failures are caught, so a bad webhook can't break the form or leak an error to the client.
  • ON CONFLICT DO NOTHING + follow-up UPDATE keeps repeat sign-ups silent and the response identical for new and known addresses.

Small nit, optional: the COUNT(*) per sign-up is fine at this volume, just worth remembering if the list gets big. Safe to merge from my read.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants