Merge PR #281: fall back to video playback for downloads on download-disabled shares

This commit is contained in:
Alan Grainger
2026-08-20 07:31:59 +12:00
6 changed files with 89 additions and 23 deletions
+40 -1
View File
@@ -1,7 +1,7 @@
import { describe, it, expect, vi, beforeEach } from 'vitest'
import { AssetType, ImageSize } from '../src/types'
import type { Asset } from '../src/types'
import { resolveImageEndpoint, requiresOriginal } from '../src/gallery/sizing'
import { isVideoAsset, resolveDownloadEndpoint, resolveImageEndpoint, requiresOriginal } from '../src/gallery/sizing'
/*
resolveImageEndpoint reads `ipp.maxDownloadQuality` and `ipp.maxZoomQuality`
@@ -47,6 +47,14 @@ describe('requiresOriginal', () => {
})
})
describe('isVideoAsset', () => {
it('accepts either the asset type or the original MIME type as the video signal', () => {
expect(isVideoAsset(video)).toBe(true)
expect(isVideoAsset(videoMimeImage)).toBe(true)
expect(isVideoAsset(jpeg)).toBe(false)
})
})
describe('thumbnail - always the grid poster, never clamped', () => {
it('serves thumbnail as-is for every asset type', () => {
for (const a of [jpeg, heic, gif, video, videoMimeImage]) {
@@ -122,3 +130,34 @@ describe('gif / video (requiresOriginal) - always the original file, ceilings by
}
})
})
describe('download endpoint', () => {
it('keeps videos on /original when Immich allows original downloads', () => {
cfg['ipp.maxDownloadQuality'] = 'preview'
expect(resolveDownloadEndpoint(video, true)).toEqual({
subpath: '/original', attachment: true, servedSize: ImageSize.original
})
})
it('falls back to video playback when Immich blocks original downloads', () => {
cfg['ipp.maxDownloadQuality'] = 'preview'
expect(resolveDownloadEndpoint(video, false)).toEqual({
subpath: '/video/playback', attachment: true, servedSize: ImageSize.original
})
expect(resolveDownloadEndpoint(videoMimeImage, false).subpath).toBe('/video/playback')
})
it('keeps image downloads on the maxDownloadQuality policy', () => {
cfg['ipp.maxDownloadQuality'] = 'preview'
expect(resolveDownloadEndpoint(jpeg, false)).toEqual({
subpath: '/thumbnail', sizeQueryParam: 'preview', attachment: true, servedSize: ImageSize.preview
})
})
it('keeps animated image downloads on /original', () => {
cfg['ipp.maxDownloadQuality'] = 'preview'
expect(resolveDownloadEndpoint(gif, false)).toEqual({
subpath: '/original', attachment: true, servedSize: ImageSize.original
})
})
})