mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-04 18:04:18 +00:00
feat(plugins): let a plugin attach a photo to a journal entry
A journal importer can create the journey, create its entries and write their stories, and then it stops: there was no way to give an entry a picture. The seven journal.* methods cover text and nothing else, so an importer reading an export archive could only upload its photos as trip files, which live on a trip and never reach the journey's gallery. journal.addEntryPhoto takes the bytes. Deliberately not a link to an existing gallery photo and not a provider asset: an importer holding an archive has neither, it has a file it just unpacked. The access decision stays where it already was. addPhoto answers null unless the acting user may edit the journey the entry belongs to, and null becomes RESOURCE_FORBIDDEN here, so a plugin reaches exactly the entries its acting user does. Everything the REST upload refuses, this refuses too: images only and no SVG, the operator's allowed-file-types setting, 10MB decoded, demo mode. The stored filename is the host's, never the plugin's, because the gallery dedupes on file_path. The object is written before any row points at it and removed again when the link is refused. JournalRpc moves into its own module for this. It now needs StorageService and the EXIF backfill out of MemoriesModule, and JourneyDomainModule exists precisely so places, assignments and the plugin host can reach a few journey functions without dragging both photo providers into their graphs. Discussion #1365
This commit is contained in:
@@ -203,6 +203,15 @@ export interface PluginContext {
|
||||
getEntries(journeyId: number): Promise<unknown[]>;
|
||||
/** Create an entry on a journey the acting user can edit. Needs 'db:write:journal'. */
|
||||
createEntry(journeyId: number, input: { entry_date: string; [k: string]: unknown }): Promise<unknown>;
|
||||
/**
|
||||
* Attach a photo to an entry, bytes included. Needs 'db:write:journal'.
|
||||
*
|
||||
* For an importer that holds an export archive: it has bytes, not a gallery
|
||||
* photo to point at and not a provider asset. 'name' supplies the extension
|
||||
* only, the stored filename is the host's. Images only, no SVG, 10MB decoded,
|
||||
* and the operator's allowed-file-types setting applies.
|
||||
*/
|
||||
addEntryPhoto(entryId: number, input: { name: string; content_base64: string; caption?: string }): Promise<unknown>;
|
||||
/** Update an entry (owner/contributor-gated). Needs 'db:write:journal'. */
|
||||
updateEntry(entryId: number, input: Record<string, unknown>): Promise<unknown>;
|
||||
/** Delete an entry (owner/contributor-gated). Needs 'db:write:journal'. */
|
||||
@@ -836,6 +845,7 @@ export function createPluginContext(
|
||||
listMine: () => t.rpc('journal.listMine', { _inv: invocationId }) as Promise<unknown[]>,
|
||||
getEntries: (journeyId) => t.rpc('journal.getEntries', { journeyId, _inv: invocationId }) as Promise<unknown[]>,
|
||||
createEntry: (journeyId, input) => t.rpc('journal.createEntry', { journeyId, input, _inv: invocationId }),
|
||||
addEntryPhoto: (entryId, input) => t.rpc('journal.addEntryPhoto', { entryId, input, _inv: invocationId }),
|
||||
updateEntry: (entryId, input) => t.rpc('journal.updateEntry', { entryId, input, _inv: invocationId }),
|
||||
deleteEntry: (entryId) => t.rpc('journal.deleteEntry', { entryId, _inv: invocationId }) as Promise<{ deleted: boolean }>,
|
||||
createJourney: (input) => t.rpc('journal.createJourney', { input, _inv: invocationId }),
|
||||
|
||||
Reference in New Issue
Block a user