Files
evig/scripts/db/migrations/127_site_suggestions.sql
Mao NakamotoandClaude Opus 4.8 b64709eada fix(feedback): unblock deck comments (CSRF) + make site feedback reliable
Presentation comments were dead in prod: the static decks are served outside
middleware, so a reader has no CSRF cookie and the POST always failed
'CSRF validation failed'. Exempt /api/presentations/comments from CSRF (like
the webhook endpoints) and compensate with per-IP rate limiting + the honeypot.

Site feedback widget (/api/suggestions) was email-only and silently lossy —
sendCustomEmail resolves {success:false} instead of throwing, so failed
delivery went unnoticed. Now:
- persists to site_suggestions (migration 127) — the reliable channel
- notifies super admins in-app (bell) per submission
- still emails the team, but CHECKS the result and logs failures
- new admin page /admin/feedback to browse, resolve, copy-as-prompt
- route test updated (13/13) for the new persistence/notify/auth side channels

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-13 17:56:42 +02:00

25 lines
1001 B
SQL

-- Site feedback / suggestions
-- The floating "Vorschlag / Feedback" widget on public pages (SuggestionButton)
-- previously POSTed to /api/suggestions which only sent a fire-and-forget email.
-- With prod email deliverability unreliable, submissions could be lost silently.
-- This table makes persistence the reliable channel; email + in-app notification
-- are best-effort on top.
CREATE TABLE IF NOT EXISTS site_suggestions (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
suggestion TEXT NOT NULL,
contact TEXT,
page TEXT,
url TEXT,
page_title TEXT,
page_section TEXT,
scope TEXT,
selected_elements JSONB,
author_user_id UUID REFERENCES users(id) ON DELETE SET NULL,
resolved BOOLEAN NOT NULL DEFAULT FALSE,
created_at TIMESTAMPTZ NOT NULL DEFAULT now()
);
CREATE INDEX IF NOT EXISTS site_suggestions_unresolved_idx
ON site_suggestions (resolved, created_at DESC);