mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-30 16:33:16 +00:00
fix(journey): keep an iPhone photo's capture time and place through the HEIC conversion
The browser converts a HEIC to a JPEG before it uploads it, and that JPEG carries no EXIF, so iPhone photos arrived without their capture time and GPS. A small lazily loaded reader now takes DateTimeOriginal with its offset and the GPS pair from the HEIC's Exif item before the conversion, and journey photo uploads (gallery, entry, Studio) send them as optional taken_at, lat and lng fields. The server reads those fields leniently (an ISO instant between 1900 and tomorrow, a pair inside the globe that is not 0,0) and hands them to the capture backfill only when the request carried one file. They fill in only what the file's own EXIF lacks and go through the existing COALESCE write, so a stored value is never replaced. Covers and place images keep the plain conversion and never carry a location.
This commit is contained in:
@@ -374,13 +374,34 @@ export type JourneyEntryUpdateRequest = z.infer<typeof journeyEntryUpdateRequest
|
||||
* uploaded' for the empty case. Without this the pipe would answer
|
||||
* 'body: Invalid input: expected object' first and the message would change.
|
||||
*/
|
||||
/**
|
||||
* When and where an uploaded photo was taken, as the client read it from a HEIC
|
||||
* before converting it to a JPEG that no longer carries it (#3120). Multipart
|
||||
* text fields: `taken_at` an ISO instant, `lat` and `lng` decimal degrees. Kept
|
||||
* loose on purpose, as strings within a length: the server reads them with
|
||||
* `captureHintFrom` and quietly drops one that is not a real time or place, so
|
||||
* a bad hint never costs the photo its upload. The file's own EXIF wins over
|
||||
* them, and a stored value is never replaced.
|
||||
*/
|
||||
export const journeyPhotoCaptureFieldsSchema = z.object({
|
||||
taken_at: z.string().max(40).optional(),
|
||||
lat: z.string().max(32).optional(),
|
||||
lng: z.string().max(32).optional(),
|
||||
});
|
||||
export type JourneyPhotoCaptureFields = z.infer<typeof journeyPhotoCaptureFieldsSchema>;
|
||||
|
||||
export const journeyEntryPhotoUploadRequestSchema = z
|
||||
.looseObject({
|
||||
caption: z.unknown().optional(),
|
||||
...journeyPhotoCaptureFieldsSchema.shape,
|
||||
})
|
||||
.optional();
|
||||
export type JourneyEntryPhotoUploadRequest = z.infer<typeof journeyEntryPhotoUploadRequestSchema>;
|
||||
|
||||
/** The text fields beside a gallery photo upload: only its capture hint. Absent body, as above. */
|
||||
export const journeyGalleryPhotoUploadRequestSchema = journeyPhotoCaptureFieldsSchema.optional();
|
||||
export type JourneyGalleryPhotoUploadRequest = z.infer<typeof journeyGalleryPhotoUploadRequestSchema>;
|
||||
|
||||
/** Multipart field alongside the uploaded video — absent body for the same reason. */
|
||||
export const journeyGalleryVideoRequestSchema = z
|
||||
.looseObject({
|
||||
|
||||
Reference in New Issue
Block a user