mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-03 01:28:55 +00:00
411ec4af59
Public trip and journey share links handed out more than the owner chose to share: - A travel-only trip link still returned every day's title, and every link with the map returned the free-text day notes the shared page never shows. Days now go out through a public projection without notes, and travel-only links carry no day titles. Day notes, packing, budget and chat use explicit field lists too, and the category list holds only the categories the shared places use, without creator ids. - The public journey payload spread whole entry and photo rows, including storage keys (file_path, thumbnail_path) and internal fields. It is now built from allow-lists and pinned by a strict response contract. - /uploads/journey served every entry photo, original and video to anyone who knew the file name, so a URL kept working after a share link was revoked or the gallery switched off. It now serves journey covers and other non-entry objects only; entry media go through the token-checked proxy. - Anonymous byte paths served stored originals unchanged, so EXIF GPS left the server even with map sharing off. Every public path (journey share proxy, covers, trip share photos, public uploads) now sends a copy with location data blanked in place (EXIF GPS, XMP and IPTC location, MP4/MOV location atoms), falling back to a metadata-free re-encode or a 404, never the raw file. Owners and members still get their originals. - An entry's visibility field never decided the share link but was offered by MCP and the assistant as if it did. It is now documented as having no effect and no longer shown as a privacy label; is_draft keeps an entry off the link.
93 lines
3.5 KiB
TypeScript
93 lines
3.5 KiB
TypeScript
import { idSchema } from '../common/primitives.schema';
|
|
|
|
import { z } from 'zod';
|
|
|
|
/**
|
|
* What GET /api/public/journey/:token answers: a journey as a reader without an
|
|
* account sees it.
|
|
*
|
|
* Unlike the other response schemas, every object here is strict on purpose. The payload used to spread whole
|
|
* rows, so storage keys (`journey/<uuid>.jpg`), provider asset ids, the author
|
|
* and columns nothing on the page reads all went out with it. A key that is not
|
|
* named below now fails the route's response contract in every test that
|
|
* reaches it, rather than quietly reaching the public.
|
|
*/
|
|
|
|
/**
|
|
* A photo on the public page, inline in an entry or in the gallery. Bytes are
|
|
* fetched by `photo_id` through the share token, so no path or asset id is
|
|
* needed. The capture coordinates are null unless the owner shared the map.
|
|
*/
|
|
export const journeyPublicPhotoSchema = z.strictObject({
|
|
/** The gallery row: the page's key for the photo. */
|
|
id: idSchema,
|
|
/** The TREK photo, what /api/public/journey/:token/photos/:photoId/:kind serves. */
|
|
photo_id: idSchema,
|
|
caption: z.string().nullable(),
|
|
media_type: z.string().nullable(),
|
|
width: z.number().nullable(),
|
|
height: z.number().nullable(),
|
|
duration_ms: z.number().nullable(),
|
|
taken_at: z.string().nullable(),
|
|
lat: z.number().nullable(),
|
|
lng: z.number().nullable(),
|
|
/** A clip without a poster frame: its thumbnail route 404s, so the page draws a plain tile (#2341). */
|
|
posterless: z.boolean(),
|
|
/**
|
|
* Clips only, deprecated: 'local' or the provider's name. App builds and
|
|
* cached pages from before `posterless` read it to decide on the poster; it
|
|
* names no file. Drop it once those have aged out.
|
|
*/
|
|
provider: z.string().nullable().optional(),
|
|
});
|
|
export type JourneyPublicPhoto = z.infer<typeof journeyPublicPhotoSchema>;
|
|
|
|
/**
|
|
* An entry on the public page. A map-only share carries just what plots a
|
|
* marker, so the narrative fields are optional; the coordinates are null
|
|
* unless the map is shared.
|
|
*/
|
|
export const journeyPublicEntrySchema = z.strictObject({
|
|
id: idSchema,
|
|
type: z.string(),
|
|
entry_date: z.string(),
|
|
entry_time: z.string().nullable().optional(),
|
|
sort_order: z.number().nullable(),
|
|
title: z.string().nullable(),
|
|
story: z.string().nullable().optional(),
|
|
location_name: z.string().nullable(),
|
|
location_lat: z.number().nullable(),
|
|
location_lng: z.number().nullable(),
|
|
country_code: z.string().nullable().optional(),
|
|
mood: z.string().nullable().optional(),
|
|
weather: z.string().nullable().optional(),
|
|
tags: z.array(z.string()).optional(),
|
|
pros_cons: z.record(z.string(), z.unknown()).nullable().optional(),
|
|
photos: z.array(journeyPublicPhotoSchema).optional(),
|
|
});
|
|
export type JourneyPublicEntry = z.infer<typeof journeyPublicEntrySchema>;
|
|
|
|
export const journeyPublicResponseSchema = z.strictObject({
|
|
journey: z.strictObject({
|
|
title: z.string(),
|
|
subtitle: z.string().nullable(),
|
|
/** The cover's upload name, rendered through /uploads. */
|
|
cover_image: z.string().nullable(),
|
|
status: z.string().nullable(),
|
|
show_verdict: z.number(),
|
|
show_mood: z.number(),
|
|
show_weather: z.number(),
|
|
}),
|
|
entries: z.array(journeyPublicEntrySchema),
|
|
gallery: z.array(journeyPublicPhotoSchema),
|
|
stats: z.strictObject({ entries: z.number(), photos: z.number(), places: z.number() }),
|
|
cartoApiKey: z.string(),
|
|
permissions: z.strictObject({
|
|
share_timeline: z.boolean(),
|
|
share_gallery: z.boolean(),
|
|
share_map: z.boolean(),
|
|
newest_first: z.boolean(),
|
|
}),
|
|
});
|
|
export type JourneyPublicResponse = z.infer<typeof journeyPublicResponseSchema>;
|