H1: auth extractor re-reads the live user row — trusts the DB role (not the
JWT claim) and rejects banned users mid-session. e2e proves a demoted
host loses powers and a banned host is locked out and can't self-unban.
H2: client_ip takes the right-most XFF hop (the one Caddy appends); spoofed
left-most entries are ignored, restoring IP-based throttles.
H3: Caddy excludes /api/v1/stream from `encode` so SSE isn't buffered.
H4: upload — quota increment + row insert + hashtag links now one txn.
H5: feed keyset pagination tiebroken on (created_at, id) + composite index
(migration 010); feed_delta bounded with LIMIT.
H7: LightboxModal keys its comment load off upload.id, ending the
SSE-driven refetch storm.
H8: CSP via SvelteKit kit.csp (svelte.config.js) hardens the localStorage
token model against injection.
Migration 010 also adds the latent comment/comment_hashtag indexes.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
18 lines
734 B
SQL
18 lines
734 B
SQL
-- Composite feed index with an id tiebreaker so keyset pagination
|
|
-- (ORDER BY created_at DESC, id DESC) stays index-covered and stable when
|
|
-- multiple uploads share a created_at timestamp.
|
|
CREATE INDEX idx_upload_event_created_id
|
|
ON upload(event_id, created_at DESC, id DESC)
|
|
WHERE deleted_at IS NULL;
|
|
|
|
-- A user's own comments (moderation, "who commented"). The sibling
|
|
-- idx_upload_user already exists for uploads; comment(user_id) was missing.
|
|
CREATE INDEX idx_comment_user
|
|
ON comment(user_id)
|
|
WHERE deleted_at IS NULL;
|
|
|
|
-- Hashtag filtering over comments — mirrors idx_upload_hashtag_hashtag, which
|
|
-- only covered upload_hashtag.
|
|
CREATE INDEX idx_comment_hashtag_hashtag
|
|
ON comment_hashtag(hashtag_id);
|