Skip to content

Fix NOTIFY-MENTION: Replace edge function with API route#153

Merged
bmoss2015 merged 5 commits into
mainfrom
fix/notify-mention-api-route
Jun 18, 2026
Merged

Fix NOTIFY-MENTION: Replace edge function with API route#153
bmoss2015 merged 5 commits into
mainfrom
fix/notify-mention-api-route

Conversation

@bmoss2015

Copy link
Copy Markdown
Owner

Why

The notify-mention Supabase edge function disappeared in the June 15 Supabase project rotation. list_edge_functions returns zero on rsdmyydyhqgkkvwlklif, so every @mention email from a lead discussion has been silently dropping (the catch in postComment swallowed the failed sb.functions.invoke).

What

  • New API route src/app/api/notifications/mention/route.ts (Node runtime, Resend SDK, shared-secret auth via x-internal-secret).
  • postComment in _discussion-actions.ts now POSTs to that route instead of invoking the missing edge function.
  • Email body matches the edge function output exactly: gradient bar, 200px logo, "Mention" eyebrow, headline, intro, comment in #f5f5f5 rounded box, "Open the Discussion" gradient button, footer line.
  • Template now imported from the single source of truth in src/lib/email-template.ts instead of being duplicated inside the edge function.

Follow up before merge

INTERNAL_API_SECRET must 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

  • Confirm Vercel preview build is green
  • On the preview URL, sign in (info@mossyland.com / MossEquity-858dc58d33!) and add a lead discussion comment that @mentions another teammate
  • Verify the mentioned user receives the email with gradient bar, logo, eyebrow, headline, intro, gray comment box, button, footer
  • Posting still succeeds even if the email step fails

After merge

  • Delete supabase/functions/notify-mention/ in a follow up PR

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).
@vercel

vercel Bot commented Jun 18, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
moss-equity-portal Ready Ready Preview, Comment Jun 18, 2026 5:12pm

Request Review

@supabase

supabase Bot commented Jun 18, 2026

Copy link
Copy Markdown

This pull request has been ignored for the connected project rsdmyydyhqgkkvwlklif because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

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.
@bmoss2015 bmoss2015 merged commit 2a446f8 into main Jun 18, 2026
4 checks passed
@bmoss2015 bmoss2015 deleted the fix/notify-mention-api-route branch June 18, 2026 17:13
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.

1 participant