diff options
| author | Fuwn <[email protected]> | 2026-02-07 05:03:35 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2026-02-07 05:03:35 -0800 |
| commit | 17f0f1877764e9c1d79a2b86dac8ff2110aa6a34 (patch) | |
| tree | 1cabf70d230dc614c3ee2408bdc0acaf13a502d8 /apps/web/app/api/webhook-config | |
| parent | feat: dynamically compute sidebar max width from item text widths (diff) | |
| download | asa.news-17f0f1877764e9c1d79a2b86dac8ff2110aa6a34.tar.xz asa.news-17f0f1877764e9c1d79a2b86dac8ff2110aa6a34.zip | |
fix: api key prefix rename, revoke fix, and webhook validation
Rename API key prefix from asn_ to asa_, fix key revoke by aligning
response property names with frontend interface, and add server/client
validation to prevent enabling webhooks without a URL.
Diffstat (limited to 'apps/web/app/api/webhook-config')
| -rw-r--r-- | apps/web/app/api/webhook-config/route.ts | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/apps/web/app/api/webhook-config/route.ts b/apps/web/app/api/webhook-config/route.ts index 049f4f3..bd38d0f 100644 --- a/apps/web/app/api/webhook-config/route.ts +++ b/apps/web/app/api/webhook-config/route.ts @@ -91,10 +91,29 @@ export async function PUT(request: Request) { } if (typeof body.webhookEnabled === "boolean") { - updates.webhook_enabled = body.webhookEnabled if (body.webhookEnabled) { + const { data: currentProfile } = await adminClient + .from("user_profiles") + .select("webhook_url") + .eq("id", user.id) + .single() + + const effectiveUrl = + typeof body.webhookUrl === "string" + ? body.webhookUrl.trim() + : currentProfile?.webhook_url + + if (!effectiveUrl) { + return NextResponse.json( + { error: "cannot enable webhooks without a url" }, + { status: 400 } + ) + } + updates.webhook_consecutive_failures = 0 } + + updates.webhook_enabled = body.webhookEnabled } if (Object.keys(updates).length === 0) { |