diff --git a/server/src/nest/journey/journey.controller.ts b/server/src/nest/journey/journey.controller.ts index df4d75288..d372b9a2b 100644 --- a/server/src/nest/journey/journey.controller.ts +++ b/server/src/nest/journey/journey.controller.ts @@ -476,7 +476,7 @@ export class JourneyController { // ── Gallery (prefix /:id/gallery — before /:id) ───────────────────────── @Post(':id/gallery/photos') @UseInterceptors(FilesInterceptor('photos')) - async uploadGalleryPhotos(@CurrentUser() user: User, @Param('id') id: string, @UploadedFiles() files: Express.Multer.File[] | undefined, @Body() body: JourneyGalleryPhotoUploadDto) { + async uploadGalleryPhotos(@CurrentUser() user: User, @Param('id') id: string, @UploadedFiles() files: Express.Multer.File[] | undefined, @Body() body?: JourneyGalleryPhotoUploadDto) { this.refuseDemoUpload(user, files ?? []); if (!files?.length) { throw new HttpException({ error: 'No files uploaded' }, 400); diff --git a/server/tests/e2e/journey.e2e.test.ts b/server/tests/e2e/journey.e2e.test.ts index b96e168e8..f7097f4bc 100644 --- a/server/tests/e2e/journey.e2e.test.ts +++ b/server/tests/e2e/journey.e2e.test.ts @@ -625,7 +625,7 @@ describe('Journey e2e (real auth guard + temp SQLite)', () => { expect(res.body.photos).toHaveLength(1); // The capture backfill runs for the upload (and may place its entry, #1003)... await new Promise((resolve) => setTimeout(resolve, 10)); - expect(backfillRun).toHaveBeenCalledWith([90], 1); + expect(backfillRun).toHaveBeenCalledWith([90], 1, undefined); // ...but no journey refresh follows: a bulk upload would otherwise reload // every open client once per photo. expect(jsvc.broadcastJourneyEvent).not.toHaveBeenCalled(); diff --git a/server/tests/unit/nest/journey.controller.test.ts b/server/tests/unit/nest/journey.controller.test.ts index 44341fdb4..525d3e2aa 100644 --- a/server/tests/unit/nest/journey.controller.test.ts +++ b/server/tests/unit/nest/journey.controller.test.ts @@ -199,10 +199,20 @@ describe('JourneyController', () => { ]); // The client uploads one file per request, so a refresh per upload would // reload every open client once per photo: uploads backfill and stay quiet. + // No capture fields came along, so no hint does either (#3120). expect(scheduleUpload.mock.calls).toEqual([ - [[entryPhoto], 1], - [[galleryPhoto], 1], + [[entryPhoto], 1, null], + [[galleryPhoto], 1, null], ]); + scheduleUpload.mockClear(); + const fields = { taken_at: '2026-05-30T13:52:19.000Z', lat: '64.1466000', lng: '-21.9426000' }; + const hint = { takenAt: '2026-05-30T13:52:19.000Z', lat: 64.1466, lng: -21.9426 }; + await c.uploadGalleryPhotos(user, '9', [{ filename: 'g.jpg' } as Express.Multer.File], fields); + await c.uploadEntryPhotos(user, '3', [{ filename: 'a.jpg', originalname: 'a.jpg' } as Express.Multer.File], fields); + // Two files in one request: the hint names neither of them. + const two = [{ filename: 'g.jpg' }, { filename: 'h.jpg' }] as Express.Multer.File[]; + await c.uploadGalleryPhotos(user, '9', two, fields); + expect(scheduleUpload.mock.calls.map((call) => call[2])).toEqual([hint, hint, null]); }); it('link-photo: 400 without id (accepts legacy photo_id), 403, success, and the asking tab is skipped', async () => { diff --git a/shared/src/journey/journey.schema.spec.ts b/shared/src/journey/journey.schema.spec.ts index 9ab6014a4..608e64d38 100644 --- a/shared/src/journey/journey.schema.spec.ts +++ b/shared/src/journey/journey.schema.spec.ts @@ -5,6 +5,8 @@ import { journeyContributorRequestSchema, journeyContributorUpdateRequestSchema, journeyPhotosDeleteToolSchema, + journeyEntryPhotoUploadRequestSchema, + journeyGalleryPhotoUploadRequestSchema, journeyProviderPhotosRequestSchema, journeyShareLinkRequestSchema, journeyUpdateRequestSchema, @@ -91,6 +93,21 @@ describe('journeyContributorUpdateRequestSchema', () => { }); }); +describe('photo upload capture fields (#3120)', () => { + it('takes the capture fields as strings beside the file, and no body at all', () => { + const fields = { taken_at: '2026-05-30T13:52:19.000Z', lat: '64.1466000', lng: '-21.9426000' }; + expect(journeyGalleryPhotoUploadRequestSchema.safeParse(fields).success).toBe(true); + expect(journeyGalleryPhotoUploadRequestSchema.safeParse(undefined).success).toBe(true); + expect(journeyEntryPhotoUploadRequestSchema.safeParse({ caption: 'x', ...fields }).success).toBe(true); + }); + + it('refuses a field that is not a string or is far too long to be a time or a coordinate', () => { + expect(journeyGalleryPhotoUploadRequestSchema.safeParse({ lat: 64.1 }).success).toBe(false); + expect(journeyGalleryPhotoUploadRequestSchema.safeParse({ taken_at: 'x'.repeat(41) }).success).toBe(false); + expect(journeyEntryPhotoUploadRequestSchema.safeParse({ lng: 'y'.repeat(33) }).success).toBe(false); + }); +}); + describe('journeyPhotosDeleteToolSchema', () => { it('takes one journey and 1 to 100 photo ids', () => { expect(journeyPhotosDeleteToolSchema.safeParse({ journeyId: 1, journey_photo_ids: [2, 3] }).success).toBe(true);