Commit Graph
84 Commits
Author SHA1 Message Date
adamfandClaude Code ff186f04a7 Spotify unauthenticated: throttled log + admin reconnect on Listening widget
Deploy with Docker Compose / deploy (push) Successful in 40s
- Backend logs a rate-limited (1/h) "not authenticated" line when a resolver
  finds the Spotify client nil instead of silently degrading to null.
- New public-but-gated spotifyNeedsReauth query: false for everyone except
  an admin session whose backend has no client.
- The /stp Listening widget offers admins a "Reconnect Spotify" button that
  hits /api/spotify/auth and navigates to the returned authorisation URL;
  non-admins still see the widget degrade as before.

Co-Authored-By: Claude Code <[email protected]>
2026-09-22 22:54:48 +01:00
adamfandClaude Code 50c2fdfdd1 Harden job-application tracker: backend fixes, tests, UI rework
Deploy with Docker Compose / deploy (push) Successful in 1m8s
Backend (email sync + resolvers):
- Sync window anchored on latest received_at with slack + rewind age-out
- Skip ctx-cancelled per-email side effects
- Soft-deleted applications no longer block pipeline matching
- Status normalization shared between pipeline and resolvers, with tests
- Reject empty jobTitle/company on create/update
- IMAP fallback synthesizes Message-ID from stable message traits
- Consistent list ordering with id tie-break

Frontend (JobApplications.vue):
- Unified status vocabulary with pipeline (lowercase keys)
- Emptied optional fields now clear on save; row stays open on failure
- URL editable, notes textarea, appliedAt defaults to today
- Error banner, delete confirmations, inline status select
- Search, sortable columns, status-count filter tiles, stale-row marker
- CSV export with UTF-8 BOM + CRLF

Tests: stdlib table-driven tests for sync, status, auth, handlers.

Co-Authored-By: Claude Code <[email protected]>
2026-09-22 22:31:30 +01:00
adamfandClaude Opus 5 25ac1cde1c Fix security issues, bugs, and convoluted code across the stack
Security:
- Token revocation. User gains a TokenVersion counter embedded in both
  tokens as a "tv" claim; AuthenticateToken rejects a token whose version
  no longer matches the row. Logout bumps it, so logging out now kills
  outstanding tokens rather than only clearing cookies. Costs one
  primary-key SELECT per authenticated request, which is the price of
  having revocation at all.
- Spotify OAuth CSRF. The fixed SPOTIFY_AUTH_STATE constant is replaced by
  a per-request one-shot nonce, verified and consumed on callback.
- Private chat attachments. Attachments on private messages are written to
  /backend/uploads/private/ and served at /uploads/private/, gated by the
  same nginx auth_request admin check used for /hasura/ and /notes/.
  Private uploads are rejected from non-admin callers.
- The icecast admin UI (/radio/admin/) is behind the admin gate; listener
  traffic is untouched.
- Store caches are mutex-guarded, so -race is clean.

Bugs:
- The email pipeline no longer drops emails permanently on transient
  failure. Failures record an attempt counter and are retried up to 3
  times; the fetch window rewinds to the oldest retryable email's
  ReceivedAt, without which a retry could never re-fetch it.
- Rowing duplicate detection distinguishes ErrRecordNotFound from a real
  DB error, so a transient failure no longer causes a duplicate insert
  plus a paid Claude call.
- DeletePost propagates its delete error instead of reporting success.
- RecentlyPlayed populates the cache it reads.
- main.go exits non-zero if r.Run fails, so a port conflict is visible.
- Python: the scan truncation flag is set on every deadline path;
  timed_out is reported by the worker rather than inferred from the clock;
  date validation uses Europe/London rather than server-local time.
- Vue: Time.vue and Radio.vue intervals are cleared on unmount; Feed.vue
  guards a missing author; Timer.vue gets an explicit state machine and
  compares total elapsed seconds; Elle.vue's comma-operator call and
  per-frame console.log are fixed.

Simplification:
- One TTLCache replaces three near-identical cache implementations, with
  the differing eviction rules as explicit parameters.
- run_scan's transport index no longer uses one object as both ordering
  record and live output; its three phases are separate functions.
- _price_hotels submits all work to a single pool, so the nested-executor
  deadlock hazard is gone by construction.
- The NDJSON event generators share one implementation.
- IMAP FETCH responses pair each line with its literal in the type, so
  callers no longer hand-skip alternate entries.
- Shared helpers for slice-of-pointers, markdown fences and auth cookies.
- Vue: useHotelSearch, createMirrorStore, useRotation, useCreateForm,
  useLinkAttrs, ListWidget and LinkTableItems replace duplicated blocks.
- nginx dev config's duplicated :80/:443 bodies share one partial.

Infra: certbot passes --deploy-hook touching a sentinel that nginx's
watcher reloads on, so renewed certs are served without a restart, and the
watcher also removes the manual restart after first issuance. db is gated
on service_healthy, autoheal is pinned, and the unused envsubst entries
are dropped.

Verified: go build/vet, npx vite build, py_compile, docker compose config
for both overlays, bash -n on all scripts, and an envsubst render of every
nginx template (no leftover placeholders, runtime vars preserved, braces
balanced).

Co-Authored-By: Claude Opus 5 <[email protected]>
2026-09-16 16:12:21 +01:00
adamfandClaude Opus 5 64df70e5d2 Document codebase: comments, per-area READMEs, deployment guide
Readability pass across all four areas of the stack. Comments explain why
rather than what, concentrated at the points where behaviour is non-obvious:
concurrency, caching, auth, scraping and nginx templating.

Backend: doc comments on every exported declaration across handlers,
services, models and resolvers. Resolver commentary lives inside function
bodies so gqlgen does not strip it on regeneration; schema files use #
comments rather than description blocks so introspection output is
unchanged. Extracted the duplicated auth-cookie blocks into helpers.

Frontend: header comments on every component, store and view, including
STATUS: notes marking which of the parallel/legacy views are still live.
Documented the non-reactive animation-state pattern, the homeData hub and
the WebSocket stale-socket guard. Removed a few dead imports and named the
reconnect-backoff and poll-interval constants.

Python: module and function docstrings covering the Travelodge scraping
contract, the deadline threading, the two-executor concurrency and the
NDJSON streaming protocol.

Infra: header blocks on every compose file, nginx template, Dockerfile and
entrypoint, covering the config selection, envsubst allow-lists, rate-limit
semantics and volume persistence. Hoisted the duplicated envsubst variable
list in nginx/entrypoint.sh.

New: backend/README.md, python/README.md, DEPLOYMENT.md, .env.example,
backend/graph/doc.go. Refreshed vue/README.md. Corrected CLAUDE.md, which
stated a 24h access token where main.go sets 7 days.

No behaviour change. go build/vet, vite build, py_compile and docker
compose config all pass.

Co-Authored-By: Claude Opus 5 <[email protected]>
2026-09-16 15:57:48 +01:00
adamfandClaude Fable 5.1 6037729edd Add admin-only private chat messages and message deletion
Deploy with Docker Compose / deploy (push) Successful in 58s
Admins can flag a chat message as private so only other admin
connections receive it, and can delete any message. Admin status is
read from the auth cookies on the WebSocket upgrade request.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
2026-09-16 15:22:26 +01:00
adamfandClaude Opus 4.6 1e22bacdc9 Add email sync service for automated job application tracking
Deploy with Docker Compose / deploy (push) Successful in 4m40s
Background poller fetches emails via IMAP or Microsoft Graph API,
classifies them with Claude Haiku, and creates/updates JobApplication
records automatically. Includes manual sync endpoint and OAuth callback.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
2026-04-15 13:59:24 +01:00
adamfandClaude Sonnet 4.6 b56f8253d9 Harden backend against critical and high security vulnerabilities
Deploy with Docker Compose / deploy (push) Successful in 3m51s
- Fix WebSocket CheckOrigin to use proper url.Parse instead of string stripping
- Add admin auth checks to Users/User GraphQL queries
- Remove GraphQL GET transport to prevent CSRF via cross-site links
- Add application-level IP-based login rate limiting (5 attempts/min)
- Add path traversal bounds check on radio file upload
- Require DEV_MODE for GraphQL introspection and playground
- Move notes backend endpoint behind admin middleware
- Add dedicated Nginx rate limit zone for GraphQL (10r/s)

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
2026-04-14 13:27:33 +01:00
adamfandClaude Sonnet 4.6 7aff171ef8 Remove REST handlers superseded by GraphQL resolvers
Deploy with Docker Compose / deploy (push) Has been cancelled
Deleted handle_activity.go, handle_favorites.go, handle_post.go, and
handle_user.go — all logic already exists in schema.resolvers.go.
Removed corresponding REST routes from main.go. Moved UserCredentials
struct (used by Login handler) into handle_auth.go.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
2026-04-14 11:08:09 +01:00
adamfandClaude Opus 4.6 c335bf14d6 Add token refresh to ValidateAdmin for seamless session renewal
Deploy with Docker Compose / deploy (push) Successful in 3m55s
When the access token is missing or expired, the handler now falls back
to the refresh token, verifies the user is still admin via DB lookup,
and issues fresh cookies in the subrequest response.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
2026-04-12 21:35:45 +01:00
adamfandClaude Opus 4.6 d344497393 Gate searxng, notes, and hasura behind admin auth via nginx auth_request
Deploy with Docker Compose / deploy (push) Has been cancelled
Add ValidateAdmin endpoint that checks JWT admin claim for use as an
nginx auth_request subrequest. Widen cookie path from backend endpoint
to "/" so the access_token is sent on all paths. Extend access token
lifetime from 24h to 7 days. Disable hasura service by default via
Docker profile.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
2026-04-12 21:33:41 +01:00
adamfandClaude Opus 4.6 a44011bf0b Add disable/enable toggle for radio fallback songs
Deploy with Docker Compose / deploy (push) Successful in 3m27s
Co-Authored-By: Claude Opus 4.6 <[email protected]>
2026-03-30 16:47:04 +01:00
adamfandClaude Opus 4.6 d215333128 Add admin UI for managing radio fallback music
Deploy with Docker Compose / deploy (push) Successful in 3m44s
Upload, list, and delete fallback music files from the admin page.
Backend handlers validate file type/size and prevent path traversal.
Nginx max body size increased to 50M to support large audio files.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
2026-03-30 16:19:10 +01:00
adamfandClaude Opus 4.6 75cede3b1b Fix security vulnerabilities across backend, frontend, and infra
Deploy with Docker Compose / deploy (push) Successful in 4m44s
- Fix auth bypass in UpdatePost/DeletePost (missing return after auth check)
- Remove Spotify access token from callback response
- Replace internal error messages with generic responses in all handlers
- Harden GraphQL: complexity limit, disable playground/introspection in prod
- Add security headers (X-Frame-Options, HSTS, etc.) to nginx
- Disable Hasura console/dev mode in production
- Add DOMPurify sanitization to Markdown component
- Fix cookie removal to use correct domain/path from auth config
- Fix nil dereference in rowing handler when Claude API errors
- Fix wildcard CORS on stamp endpoint
- Pin nginx and certbot Docker image versions

Co-Authored-By: Claude Opus 4.6 <[email protected]>
2026-03-29 23:59:10 +01:00
adamfandClaude Opus 4.6 932e257152 Add HTTPS support in dev mode and fix mobile layout issues
Deploy with Docker Compose / deploy (push) Successful in 4m19s
Generate self-signed certs for local HTTPS, add port 443 and full SSL
server block to dev nginx config, add Spotify redirect URI env var,
improve Spotify token error handling, and fix Chat/Steam mobile sizing.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
2026-03-26 11:18:32 +00:00
adamfandClaude Opus 4.6 264df132df Add Steam integration showing online status and recent games
Deploy with Docker Compose / deploy (push) Has been cancelled
Fetches player summary and recently played games from Steam API with
5-minute server-side caching. Displays in the home sidebar with online
indicator and game artwork.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
2026-03-26 01:59:34 +00:00
adamfandClaude Opus 4.6 29350af2e0 Fix WebSocket 403 in dev mode by allowing localhost origins
Deploy with Docker Compose / deploy (push) Has been cancelled
The CheckOrigin function only accepted the production domain, rejecting
localhost connections in dev. Also removed redundant error response after
a failed upgrade since the upgrader already writes its own HTTP response.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
2026-03-25 16:59:13 +00:00
adamfandClaude Sonnet 4.6 7381cda7b8 Move Gitea feed from frontend to backend with cached GraphQL proxy
Deploy with Docker Compose / deploy (push) Successful in 4m39s
Replaces direct browser-to-Gitea API calls with a backend service that
proxies and caches the feed (1-min TTL), served via the existing GraphQL
HomeData query. Commit message parsing now happens server-side.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
2026-03-17 00:14:59 +00:00
adamf bad44a6ddd Separate admin protected endpoints from non-admin endpoints 2026-03-10 12:32:47 +00:00
adamf cb326ff8bf Add promote / demote user to admin and reintroduce create user dashboard 2026-03-10 12:18:24 +00:00
adamf 68db930049 Don't use SaveUploadedFile (causing permission issues)
Deploy with Docker Compose / deploy (push) Has been cancelled
2026-03-09 17:21:26 +00:00
adamf 63da086da2 Removed setting own permissions, let dockerfile entryhost do it
Deploy with Docker Compose / deploy (push) Has been cancelled
2026-03-09 17:10:24 +00:00
adamf 7c980f1b1f Fix file permissions, still
Deploy with Docker Compose / deploy (push) Has been cancelled
2026-03-09 16:53:45 +00:00
adamf d03f9668ad Add error handling 2026-03-09 16:41:38 +00:00
adamf 41d6cf0dac omg fix undefined variable
Deploy with Docker Compose / deploy (push) Has been cancelled
2026-03-09 16:29:56 +00:00
adamf 1e3c6adf5e Fix file permissions on image upload
Deploy with Docker Compose / deploy (push) Has been cancelled
2026-03-09 16:23:44 +00:00
adamf 99ddd7d494 Fix file permissions
Deploy with Docker Compose / deploy (push) Has been cancelled
2026-03-09 16:20:47 +00:00
adamf 8e50537333 Get AI to fix vunerabilities in site
Deploy with Docker Compose / deploy (push) Has been cancelled
2026-03-09 14:12:29 +00:00
adamf 85a2325683 change file permissions to /uploads
Deploy with Docker Compose / deploy (push) Successful in 4m0s
2026-03-09 13:59:59 +00:00
adamf 0a8a752433 Add file upload to website and integrate into chat
Deploy with Docker Compose / deploy (push) Successful in 5m12s
2026-03-09 13:47:45 +00:00
adamf 2737b4f0d0 Avoid panic on spotify if not authed
Deploy with Docker Compose / deploy (push) Successful in 3m35s
2026-03-07 17:46:55 +00:00
adamf 0da6d3f0ed check duplicates before making claude request
Deploy with Docker Compose / deploy (push) Successful in 3m31s
2026-03-07 16:51:11 +00:00
adamf adcf1bda48 Check that paces are reasonable
Deploy with Docker Compose / deploy (push) Has been cancelled
2026-03-07 16:43:08 +00:00
adamf 646f93136d update rowing information to non fricken nanoseconds who though time.Durations should be nanoseconds
Deploy with Docker Compose / deploy (push) Successful in 3m45s
2026-03-04 16:48:21 +00:00
adamf e43c07b30a more verbose error response
Deploy with Docker Compose / deploy (push) Successful in 3m17s
2026-03-04 16:10:52 +00:00
adamf 190bc6076b remove json boilerplate, log error and return response
Deploy with Docker Compose / deploy (push) Successful in 2m45s
2026-03-04 15:58:14 +00:00
adamf 095cd72946 Add rowing machine endpoint 2026-03-04 14:22:05 +00:00
adamf 1d4beca336 Add claude client to store 2026-03-04 14:21:51 +00:00
adamf dbdab24e17 adding admin tools 2026-02-06 13:20:21 +00:00
adamf f546e8ae23 adding new tables 2026-02-06 12:52:52 +00:00
adamf f354e41ab7 fix fetch 2026-01-23 12:21:59 +00:00
adamf e9fb87b26f test 2026-01-23 12:05:14 +00:00
adamf eaba9c8069 websocket? 2026-01-22 10:47:02 +00:00
adamf 02d70ee5db init commit websocket 2026-01-22 10:23:33 +00:00
adamf 164c89d362 adjust frontend for any filetype and add metadata to api response 2026-01-13 12:23:36 +00:00
adamf 18c87c170b make notes api return any file (so images and etc can be sent) 2026-01-13 12:13:20 +00:00
adamf 99ace613ce added obsidian note api 2026-01-12 15:46:01 +00:00
adamf 78a86b176f changing field names 2025-12-10 17:24:40 +00:00
adamf 11487d67f4 added posts 2025-12-10 17:08:10 +00:00
adamf c15b8b9cd8 added posts 2025-12-10 17:05:17 +00:00
adamf bd59419a0e temp admin necesitity 2025-12-10 06:27:25 +00:00