Fix guest upload queue endpoint
Some checks failed
linter / quality (push) Has been cancelled
tests / ci (push) Has been cancelled
tests / ui (push) Has been cancelled

This commit is contained in:
Codex Agent
2026-01-30 13:06:26 +01:00
parent 4b1785fb85
commit 96aaea23e4
2 changed files with 16 additions and 1 deletions

View File

@@ -0,0 +1,12 @@
import { describe, expect, it } from 'vitest';
import { buildQueueUploadUrl } from '../queue';
describe('buildQueueUploadUrl', () => {
it('builds the guest upload endpoint', () => {
expect(buildQueueUploadUrl('demo-token')).toBe('/api/v1/events/demo-token/upload');
});
it('encodes event tokens safely', () => {
expect(buildQueueUploadUrl('token/with space')).toBe('/api/v1/events/token%2Fwith%20space/upload');
});
});

View File

@@ -5,6 +5,9 @@ import { createUpload } from './xhr';
import { notify } from './notify'; import { notify } from './notify';
type SyncManager = { register(tag: string): Promise<void>; }; type SyncManager = { register(tag: string): Promise<void>; };
export const buildQueueUploadUrl = (eventToken: string) =>
`/api/v1/events/${encodeURIComponent(eventToken)}/upload`;
export type QueueItem = { export type QueueItem = {
id?: number; id?: number;
eventToken: string; eventToken: string;
@@ -81,7 +84,7 @@ async function attemptUpload(it: QueueItem): Promise<boolean> {
if (!navigator.onLine) return false; if (!navigator.onLine) return false;
try { try {
const json = await createUpload( const json = await createUpload(
`/api/v1/events/${encodeURIComponent(it.eventToken)}/photos`, buildQueueUploadUrl(it.eventToken),
it, it,
getDeviceId(), getDeviceId(),
(pct) => { (pct) => {