Fix NOTIFY-MENTION: Replace edge function with API route#153
Merged
Conversation
The notify-mention edge function was lost in the June 15 Supabase project rotation and never redeployed, so postComment silently dropped every @mention email. Move the send logic into src/app/api/notifications/mention and have postComment fetch it with a shared-secret header. Email body matches the edge function exactly; Resend SDK + template helpers replace the duplicate copy that lived inside the edge function. Requires INTERNAL_API_SECRET env var on Vercel (prod + preview).
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
Server actions calling their own deployment URL via fetch is unreliable on Vercel: self-referential networking quirks plus auth handshakes for internal calls. Real @mention test from the UI posted comments and inserted notification rows but never reached the API route, so no email sent. Extract the email-send into src/lib/notifications/send-mention-email and call it directly from postComment. The /api/notifications/mention route stays as a thin shared-secret wrapper for any future external caller but is no longer in the internal hot path. Also drops the redundant footer line that restated the subject, headline, and intro. Per Linear, Notion, and Attio benchmarks, mention emails do not recap the trigger in the footer.
…t flash
Email:
- Subject and headline now read "X Mentioned You on the [Owner] Lead" so
the noun is anchored and the phrasing balanced. Drop redundant intro
line ("X left a note on Owner") that was just the headline repeated.
Lead view:
- Replace the petrol ring with a thin gradient bar on the left edge of
the comment when the URL has a comment hash anchor. Same gradient as
the email shell top bar. Animates in, holds, fades out over 2.4s.
Does NOT tint the comment background. Applied to both the email-link
landing and the in-app search-result jump for consistency.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The
notify-mentionSupabase edge function disappeared in the June 15 Supabase project rotation.list_edge_functionsreturns zero onrsdmyydyhqgkkvwlklif, so every @mention email from a lead discussion has been silently dropping (the catch inpostCommentswallowed the failedsb.functions.invoke).What
src/app/api/notifications/mention/route.ts(Node runtime, Resend SDK, shared-secret auth viax-internal-secret).postCommentin_discussion-actions.tsnow POSTs to that route instead of invoking the missing edge function.#f5f5f5rounded box, "Open the Discussion" gradient button, footer line.src/lib/email-template.tsinstead of being duplicated inside the edge function.Follow up before merge
INTERNAL_API_SECRETmust exist in Vercel for prod + preview. Generate a 32 char random string and add it; without it the route returns 401 and emails will keep dropping.Test plan
After merge
supabase/functions/notify-mention/in a follow up PR