fix(demo): journey and collab uploads are refused for the demo account too

Six upload routes refused the shared demo account in demo mode; journey photos, videos, gallery media and covers, collab note files and chat images did not, so any visitor could put images in front of every other one for the hour. They answer the same 403 now, checked in the handler after the upload is read, and a text-only chat message still goes through. The Demo Mode wiki page lists them, and says document sync is not covered.
This commit is contained in:
Maurice
2026-10-25 00:46:23 +00:00
parent 42ed858853
commit 2372dde716
11 changed files with 395 additions and 108 deletions
+5 -3
View File
@@ -3,7 +3,7 @@ import { RuntimeEnvService } from '../app-config/runtime-env.service';
import { DEMO_ACCOUNT_SETTINGS, isDemoEmail } from './demo';
import { DomainError } from './domain-error';
/** The exact 403 body the six upload endpoints have always returned. */
/** The exact 403 body the upload endpoints answer the demo account with. */
export const DEMO_WRITE_ERROR = {
error: 'Uploads are disabled in demo mode. Self-host TREK for full functionality.',
} as const;
@@ -12,9 +12,11 @@ export const DEMO_WRITE_ERROR = {
* Whether this user's writes are blocked because the instance runs in demo mode.
*
* The condition was copy-pasted into six upload handlers, each with its own copy
* of the message. It lives here once now, and every one of them calls it.
* of the message. It lives here once now, and every one of them calls it, as do
* the journey photo, video and cover uploads and the collab note file and chat
* image uploads that came without it.
*
* Deliberately a function and not a guard, though all six sites are handlers and
* Deliberately a function and not a guard, though every site is a handler and
* a guard is the obvious shape. Guards run before the multipart parser, so
* throwing from one leaves the request body unread and Node resets the
* connection: the client sees ECONNRESET instead of the 403. PROFILE-015 catches
+1 -1
View File
@@ -16,7 +16,7 @@ import { Injectable } from '@nestjs/common';
* hazard, confirmed by `task-0-report.md` §6), so an injected `EntityManager`
* resolving the current request's fork is exactly the right shape.
*
* `isDemoWriteBlocked`/`DEMO_WRITE_ERROR` (the six-upload-endpoint sibling
* `isDemoWriteBlocked`/`DEMO_WRITE_ERROR` (the upload endpoints' sibling
* check) stay exactly where they are, in `common/demo-write.ts` — a
* different, pure-function check over an already-known email string that
* this task does not touch.