Skip to content

Fix contact and comment webhook delivery - #13

Merged
Dev-Sahad merged 1 commit into
mainfrom
agent/connect-form-webhooks
Jul 30, 2026
Merged

Fix contact and comment webhook delivery#13
Dev-Sahad merged 1 commit into
mainfrom
agent/connect-form-webhooks

Conversation

@Dev-Sahad

Copy link
Copy Markdown
Owner

What changed

  • Connects Contact Me and Comments to their separate private Discord webhook settings.
  • Validates Discord webhook URLs and checks delivery responses.
  • Prevents optional Gmail delivery from blocking Contact Me notifications.
  • Waits for one comment notification request instead of launching an unchecked background request.
  • Documents environment-variable fallbacks for both webhook types.

Why

Contact delivery returned early when Gmail was unavailable, so Discord never received the message. Comment delivery was fire-and-forget and ignored Discord errors. Both paths now use one verified server-side delivery flow.

Validation

  • npm run build
  • Next.js compilation, lint, type checking, and static generation all pass.

@vercel

vercel Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

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

Project Deployment Actions Updated (UTC)
portfolio-v1 Ready Ready Preview Jul 30, 2026 8:08pm

@Dev-Sahad
Dev-Sahad marked this pull request as ready for review July 30, 2026 20:07
@Dev-Sahad
Dev-Sahad merged commit f779d57 into main Jul 30, 2026
5 of 6 checks passed
@Dev-Sahad
Dev-Sahad deleted the agent/connect-form-webhooks branch July 30, 2026 20:08

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b5258a8005

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".


return url.protocol === 'https:'
&& allowedHosts.has(url.hostname)
&& /^\/api\/webhooks\/\d+\/[A-Za-z0-9_-]+\/?$/.test(url.pathname)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Accept versioned Discord webhook paths

Discord's API also accepts webhook endpoints under versioned paths such as /api/v10/webhooks/{id}/{token}. Any existing setting using that valid form previously reached Discord through the unrestricted fetch, but this regex now rejects it before sending, causing contact submissions to return 502 and comment notifications to be dropped. Allow the optional API-version segment while retaining the host and webhook-ID checks.

Useful? React with 👍 / 👎.

Comment on lines +165 to +167
const [webhookResult, emailResult] = await Promise.allSettled([
sendDiscordWebhook(webhookUrl, webhookPayload),
sendEmail(name, email, message),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve successful email-only contact delivery

When an existing deployment has working GMAIL_USER/GMAIL_PASSWORD settings but no contact-specific Discord webhook, sendDiscordWebhook rejects even though the concurrently executed email is successfully sent, and the rejection path returns 502. This regresses the previously supported email-only configuration, tells visitors to retry a message that was already emailed and persisted, and can create duplicate emails and database rows; treat the request as delivered when either configured channel succeeds, or skip an unconfigured webhook.

Useful? React with 👍 / 👎.

const serviceKey = process.env.SUPABASE_SERVICE_ROLE_KEY

if (!url || !serviceKey) return { url: fallbackUrl || '', message: '' }
const database = getServiceDatabase()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Catch service-client construction before using the fallback

If NEXT_PUBLIC_SUPABASE_URL is present but malformed, getServiceDatabase() throws while constructing the Supabase client, and that call now occurs outside the try block. Consequently the contact route fails before reaching the configured environment webhook and the comment route returns 502, even though this function is explicitly intended to fall back to environment variables when database-backed settings are unavailable; move client construction into the guarded section.

Useful? React with 👍 / 👎.

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