mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-19 14:16:29 +00:00
fix(share): prevent unwatermarked HLS playback on public shares before transcode completion (#439)
This commit is contained in:
@@ -14,6 +14,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
||||
|
||||
### Fixed
|
||||
|
||||
- **share**: Fix an issue where videos with HLS enabled could play without watermark on public share links before watermark transcoding completed
|
||||
- **webui**: Fix an issue where legacy portrait video transcodes were mislabeled in download menus and the video player (e.g. "1920p" instead of "1080p") by correctly deriving resolution labels from the long side
|
||||
- **settings**: Fix an issue where rapid consecutive toggling of transcode resolution checkboxes could submit outdated selections or drop previous toggles
|
||||
- **webui**: Fix an issue where the resolution selector in the video seekbar displayed vertical video resolutions by long side (e.g. "Auto (3840p)") instead of standard short side (e.g. "Auto (2160p)")
|
||||
|
||||
@@ -84,7 +84,7 @@ async function applyWatermarkToAssetMedia(
|
||||
url: `/api/shares/${shareId}/files/${asset.id}/m3u8/master.m3u8${pwQuery}`,
|
||||
resolutions: watermarkMedia.hls.resolutions,
|
||||
}
|
||||
} else if (watermarkMedia) {
|
||||
} else {
|
||||
updatedMedia.isHls = false
|
||||
delete updatedMedia.hls
|
||||
}
|
||||
|
||||
@@ -277,6 +277,12 @@ describe('Share API', () => {
|
||||
},
|
||||
],
|
||||
imageTranscodes: [],
|
||||
isHls: true,
|
||||
hls: {
|
||||
key: 'files/orig-hls/master.m3u8',
|
||||
url: '/api/files/video-pending/m3u8/master.m3u8',
|
||||
resolutions: [{ resolution: '1080p', width: 1920, height: 1080 }],
|
||||
},
|
||||
original: { key: 'files/orig.mp4' },
|
||||
},
|
||||
},
|
||||
@@ -331,9 +337,11 @@ describe('Share API', () => {
|
||||
size: 0,
|
||||
},
|
||||
])
|
||||
// Pending item → original transcodes emptied
|
||||
// Pending item → original transcodes emptied and HLS cleared
|
||||
expect(body.data[1].media.videoTranscodes).toEqual([])
|
||||
expect(body.data[1].media.imageTranscodes).toEqual([])
|
||||
expect(body.data[1].media.isHls).toBe(false)
|
||||
expect(body.data[1].media.hls).toBeUndefined()
|
||||
// Non-media item → untouched
|
||||
expect(body.data[2].media.pdfTranscode).toEqual({ url: 'u', key: 'files/doc.pdf' })
|
||||
})
|
||||
@@ -478,6 +486,33 @@ describe('Share API', () => {
|
||||
expect(body.media.imageTranscodes).toEqual([])
|
||||
})
|
||||
|
||||
test('clears HLS fields while watermark transcoding is in flight', async () => {
|
||||
vi.spyOn(shareService, 'verifyPublicAccess').mockResolvedValue(shareLinkWithWatermark)
|
||||
vi.spyOn(watermarkService, 'getCompletedWatermarkMediaMap').mockResolvedValue(new Map())
|
||||
vi.spyOn(assetService, 'getAsset').mockResolvedValue({
|
||||
...videoAsset,
|
||||
media: {
|
||||
...videoAsset.media,
|
||||
isHls: true,
|
||||
hls: {
|
||||
key: 'files/hls/master.m3u8',
|
||||
url: '/api/files/file1/m3u8/master.m3u8',
|
||||
resolutions: [{ resolution: '1080p', width: 1920, height: 1080 }],
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
const res = await app.request('/shares/share1/files/file1', {
|
||||
method: 'GET',
|
||||
headers: { 'x-share-password': 'pass' },
|
||||
})
|
||||
|
||||
expect(res.status).toBe(200)
|
||||
const body = await res.json()
|
||||
expect(body.media.isHls).toBe(false)
|
||||
expect(body.media.hls).toBeUndefined()
|
||||
})
|
||||
|
||||
test('leaves non-video/image media untouched when watermark enabled', async () => {
|
||||
vi.spyOn(shareService, 'verifyPublicAccess').mockResolvedValue(shareLinkWithWatermark)
|
||||
vi.spyOn(assetService, 'getAsset').mockResolvedValue({
|
||||
|
||||
Reference in New Issue
Block a user