mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-05 10:24:05 +00:00
fix(memories): send share link viewers the Immich preview instead of the original file
A public view of an Immich image now asks for the preview rendition, which Immich re-encodes without the stored metadata, so photo locations no longer go out with share links; owners still get the fullsize original.
This commit is contained in:
@@ -200,6 +200,7 @@ export class JourneyService {
|
||||
* between them with `provider === 'immich' ? … : trySynology()`, so a third
|
||||
* provider would have been handed to Synology and 404'd from inside its
|
||||
* parser. An unregistered provider is now told apart from a failing one.
|
||||
* It goes to a share link's viewer, so the provider sends the public rendition.
|
||||
*/
|
||||
streamProviderAsset(
|
||||
res: Response,
|
||||
@@ -209,6 +210,6 @@ export class JourneyService {
|
||||
): Promise<void> | null {
|
||||
const backend = this.providers.get(provider);
|
||||
if (!backend) return null;
|
||||
return backend.streamAsset(res, ref, kind);
|
||||
return backend.streamAsset(res, { ...ref, audience: 'public' }, kind);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -520,7 +520,7 @@ export class ImmichService {
|
||||
assetId: string,
|
||||
kind: 'thumbnail' | 'original',
|
||||
ownerUserId?: number,
|
||||
opts?: { mediaType?: string | null; range?: string },
|
||||
opts?: { mediaType?: string | null; range?: string; publicView?: boolean },
|
||||
): Promise<void> {
|
||||
const effectiveUserId = ownerUserId ?? userId;
|
||||
const creds = await this.getImmichCredentials(effectiveUserId);
|
||||
@@ -548,7 +548,10 @@ export class ImmichService {
|
||||
cacheControl = 'private, max-age=3600';
|
||||
timeout = undefined;
|
||||
} else {
|
||||
url = `${creds.immich_url}/api/assets/${assetId}/thumbnail?size=fullsize`;
|
||||
// Without a generated fullsize rendition Immich answers with the original file, GPS and all;
|
||||
// its preview is re-encoded without the metadata, so that is what a share link gets.
|
||||
const size = opts?.publicView ? 'preview' : 'fullsize';
|
||||
url = `${creds.immich_url}/api/assets/${assetId}/thumbnail?size=${size}`;
|
||||
timeout = 30000;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,8 @@ export interface PhotoAssetRef {
|
||||
mediaType?: string | null;
|
||||
/** Forwarded Range header, for seeking in a video. */
|
||||
range?: string;
|
||||
/** Who the asset goes to; a share link's viewer gets an image rendered without the stored metadata. */
|
||||
audience?: 'owner' | 'public';
|
||||
}
|
||||
|
||||
export interface PhotoBytes {
|
||||
|
||||
@@ -105,8 +105,9 @@ export class PhotoResolverService {
|
||||
/**
|
||||
* A public share's view. A local file goes out as its location-free copy
|
||||
* (PublicMediaService) and never as stored; one that cannot be cleaned falls
|
||||
* back to the thumbnail TREK re-encoded itself, else a 404. Provider assets
|
||||
* stream as for an owner.
|
||||
* back to the thumbnail TREK re-encoded itself, else a 404. A provider is
|
||||
* told the asset goes to the public, so it can send a rendition without the
|
||||
* stored location in place of the original file.
|
||||
*/
|
||||
async streamPublicPhoto(
|
||||
res: Response,
|
||||
@@ -215,7 +216,7 @@ export class PhotoResolverService {
|
||||
);
|
||||
return;
|
||||
}
|
||||
await provider.streamAsset(res, { ...ref, range }, kind);
|
||||
await provider.streamAsset(res, { ...ref, range, audience }, kind);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -23,6 +23,7 @@ export class ImmichPhotoProvider implements PhotoProvider {
|
||||
return this.immich.streamImmichAsset(res, ref.userId, ref.assetId, kind, ref.ownerId, {
|
||||
mediaType: ref.mediaType,
|
||||
range: ref.range,
|
||||
publicView: ref.audience === 'public',
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user