mirror of
https://github.com/bitbaum/evig.git
synced 2026-12-04 06:17:02 +01:00
* fix(vote): give the "sign in to vote" error the door it names The vote-auth fix (#305) tells someone whose email belongs to an account to sign in, and then leaves them standing there. This repo's own rule is that every stated problem links to where it is fixed — a warning without a way out is a dead end. The reason it shipped without the link was that apiFetch flattens every failure to a bare { success, error } string. The only way for the UI to know WHICH failure it got was to match the German sentence, and branching on prose breaks the first time someone rewords or translates it. So the fix is one level down: give the envelope a machine-readable code. ERROR_CODES one SSOT for codes, next to ERROR_MESSAGES. Add one only when the interface must DO something different — the message is for the human, the code is for the UI. apiBadRequest optional third argument, omitted from the body when unset ApiResponse.code optional, so all ~100 existing callers are untouched apiFetch passes a string code through; ignores a non-string one rather than handing junk to the UI The vote page now renders "Anmelden" as a link to loginUrl beside that error, reusing the string already there for the success panel — no new i18n keys, so no locale can desync. Tests assert the passthrough and the omission, and I checked the passthrough test fails with the apiFetch change reverted (1 of 14) rather than assuming a green suite meant something. The route test now pins the code, using a mock that actually forwards the third argument — a mock that dropped it would have made the assertion vacuous. 5963 tests green across 440 suites; eslint and the umlaut linter clean. * fix(vote): the one live decision could not be voted on at all Found by opening the real share link at 390px while verifying #307, not by any test. The page drew "Deine Stimme" and then nothing. Submitting answered "Stimmdaten erforderlich". There was no ballot, and nothing on screen said why. `thumbs_up_down` has been in VOTING_METHODS all along, with a zod schema, a validator and a tally on the server — and no branch in either voting surface, and no case in useVoteState's switch. buildVoteData() fell through to `undefined`, which TypeScript allows because the switch had no default and the return type is `unknown`. So the absence compiled, rendered blank, and failed at the server. Production's only decision uses that method. Fixed on both surfaces — the public share-link page and the members' VotingPanel — with one component, and the choice labels in config beside the other methods' rather than typed into JSX. No default selection: a thumbs vote is a single deliberate tap, so pre-selecting "Dafür" would submit an opinion the voter never expressed. Two guards, because the compile-time one alone would not have caught this: useVoteState a `never` exhaustiveness default — a method with no case is now a build error rather than a silent undefined ballot-coverage.test.tsx renders EVERY entry in VOTING_METHODS and asserts the ballot contains something interactive. A missing render branch is absence, and absence is what the switch guard cannot see. It iterates the config, so it cannot drift from it. Checked the coverage test fails with the branch removed (thumbs_up_down only, 6 of 7 still passing) rather than trusting a green suite. 7747 tests green across 529 suites; eslint and the umlaut linter clean. * fix(email): the relay says 250 and the mail goes nowhere Sent a probe from the production host through the configured relay to a real mailbox. The SMTP conversation was flawless — EHLO, STARTTLS, AUTH, accepted — and the message never arrived. Not the inbox, not spam, not trash. The cause is the sender domain. EMAIL_FROM in prod is noreply@revampit.ch, which has no SPF record and no brevo._domainkey DKIM record. Brevo accepts mail from a domain it has not authenticated and then drops it, so every layer reports success and the inbox stays empty. Searching the recipient mailbox back through its whole history finds no application mail at all: every revamp-it.ch message in it is human mail from colleagues via the org's own server. evig's transactional email has never worked. scripts/test-email.ts could not have caught this. It mailed only itself, and it called a relay handoff "Email sent successfully!". So it is rebuilt to answer the question that matters: - takes the recipient as an argument instead of sending to EMAIL_FROM - resolves the sender domain's SPF, DKIM and DMARC before sending, and says plainly that an unauthenticated domain will vanish despite a 250 - refuses to describe acceptance as delivery The DKIM verdict is deliberately relay-aware. Selectors are chosen by the provider and cannot be enumerated from DNS, so a missing selector is only conclusive when we know which one to expect — Brevo documents brevo._domainkey. Against any other relay an unknown selector is reported as inconclusive, not as a failure. Checked both ways: google.com is flagged when sending through Brevo (true — it has no Brevo key) and is not flagged otherwise. Nothing here fixes delivery. That needs a sending domain that exists and is authenticated with the provider, which is a purchase and a DNS change, not a code change. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * docs: the canonical host moved, and the redirect to it must keep the method revampit.orangecat.ch now redirects to evig.orangecat.ch, so every doc that called the old host "where this codebase runs" was pointing at a redirect. It was added as `redir ... permanent`, which is 301, and 301 does not preserve the HTTP method — a POST arrives as a bodyless GET. Auth.js then answered InvalidProvider ("Callback for provider type (credentials) is not supported"), because a GET on a credentials callback is not a thing. Browser traffic never noticed: it lands on the canonical host and posts there. Only non-browser POST clients broke — the CI auth smoke, API callers, and any webhook still aimed at the old host. Fixed on the box by making it a 308; documented here so it is not reintroduced. Also records why auth-smoke and inventory-smoke deliberately point PLAYWRIGHT_BASE_URL at the OLD host: that is what exercises the redirect, and it is how this was caught. Repointing them at the canonical host would turn a real gate into a green one. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Documentation
Curated reference for engineers, operators, and contributors. Everything in this folder is meant to stay reasonably current — point-in-time work logs, incident reports, and superseded plans live under archive/.
Getting started
- SHARED_CONTEXT.md — tech stack, database, file layout
- COMMANDS.md — every npm script and what it does
- BEST_PRACTICES.md — engineering standards (logger, TABLE_NAMES, parameterized queries, Swiss-German rules)
- ARCHITECTURE_QUICK_START.md — the 10-minute architecture orientation
Architecture
- ARCHITECTURE_DATABASE_BACKEND.md — schema, Drizzle ORM, query patterns
- DATABASE_SCHEMA.md — the canonical schema reference
- UNIFIED_AUTH.md — Auth.js v5, JWT sessions, verify-code, shared admin login
- ARCHITECTURE_DEBT.md — resolved parallel-implementation debt (#1–#3 done)
- HIRN_AI.md — the in-house AI knowledge / action system
- API_DOCUMENTATION.md — public + internal API surface
Product surfaces
- FEATURE_INVENTORY.md — 155-item feature/route audit matrix (living SSOT)
- BLOG_SYSTEM.md — content pipeline + approval flow
- PROJECT_PAGES_GUIDE.md — community project pages
- SERVICE_PAGES_GUIDE.md — paid service pages
- ADMIN_QUICK_REFERENCE.md — admin surface tour for staff
- AI_BOT_SYSTEM_PROMPT.md · AI_BOT_SYSTEM_PROMPT_README.md — public chatbot system prompt + how to update it
Design
- DESIGN_SYSTEM.md — CSS-variable SSOT, semantic Tailwind, dark-mode behavior
- RESPONSIVE_DESIGN_SYSTEM.md — mobile-first responsive primitives in
src/lib/responsive.ts
Operations
- MIGRATIONS.md — canonical migration path (
scripts/db/migrations/), naming, idempotency rules, applied to the prod self-hosted Hetzner Postgres on deploy (tracked inschema_migrations) - EMAIL_SETUP.md — Listmonk + Brevo configuration
- RELIABILITY.md — uptime expectations, on-call practices
- CODE_AUDIT.md — running list of known issues being worked on
- LEGAL_NONPROFIT_COMPLIANCE.md — Swiss-Verein legal posture, data handling
Mission
- MISSION_STATEMENT.md — why this codebase exists
- CODE_OF_CONDUCT.md — community norms
Subdirectories
api/— per-route referencecomponents/— component-level notesdevelopment/— environment + workflow setupfeatures/— feature briefsguides/— how-to walkthroughshirn/— HIRN AI internalslegacy/— preserved older docsreference/— long-form reference materialarchive/— superseded plans, incident reports, completed-migration logs (preserved for history, not for navigation)