fix(server): hide original filename when not showing metadata (#27581)

This commit is contained in:
Mees Frensel
2026-04-10 12:07:18 +02:00
committed by GitHub
parent 3254d31cd2
commit 26957f37ce
2 changed files with 21 additions and 1 deletions

View File

@@ -692,6 +692,24 @@ describe(AssetMediaService.name, () => {
);
expect(mocks.asset.getForThumbnail).toHaveBeenCalledWith(asset.id, AssetFileType.Thumbnail, true);
});
it('should not include original filename if requested using a shared link with showExif false', async () => {
const asset = AssetFactory.from().file({ type: AssetFileType.Preview }).build();
mocks.access.asset.checkSharedLinkAccess.mockResolvedValue(new Set([asset.id]));
mocks.asset.getForThumbnail.mockResolvedValue({ ...asset, path: asset.files[0].path });
const auth = AuthFactory.from().sharedLink({ showExif: false }).build();
await expect(sut.viewThumbnail(auth, asset.id, { size: AssetMediaSize.PREVIEW })).resolves.toEqual(
new ImmichFileResponse({
path: asset.files[0].path,
cacheControl: CacheControl.PrivateWithCache,
contentType: 'image/jpeg',
fileName: `${asset.id}_preview.jpg`,
}),
);
});
});
describe('playbackVideo', () => {

View File

@@ -257,7 +257,9 @@ export class AssetMediaService extends BaseService {
throw new NotFoundException('Asset media not found');
}
const fileName = `${getFileNameWithoutExtension(originalFileName)}_${size}${getFilenameExtension(path)}`;
const fileNameBase =
auth.sharedLink && !auth.sharedLink.showExif ? id : getFileNameWithoutExtension(originalFileName);
const fileName = `${fileNameBase}_${size}${getFilenameExtension(path)}`;
return new ImmichFileResponse({
fileName,