fix(video): transcribe archived videos and show progress (#560)

This commit is contained in:
Yiling-J
2026-12-04 15:37:58 +08:00
committed by GitHub
parent d3899d1257
commit 72a7f68c92
21 changed files with 408 additions and 171 deletions
+24
View File
@@ -29,6 +29,30 @@ describe('Transcript API', () => {
expect(await response.json()).toEqual(list)
})
it('requires project edit access to list file IDs with active transcription', async () => {
const request = () => app.request('/projects/project-id/transcription-status')
const permission = vi
.spyOn(authzService, 'hasPermission')
.mockRejectedValue(new HTTPException(403))
const list = vi.spyOn(transcriptService, 'listActiveAssetIds').mockResolvedValue(['file-id'])
expect((await request()).status).toBe(403)
expect(list).not.toHaveBeenCalled()
permission.mockResolvedValue(undefined)
const response = await request()
expect(response.status).toBe(200)
expect(await response.json()).toEqual({ assetIds: ['file-id'] })
expect(permission).toHaveBeenLastCalledWith(
expect.objectContaining({
type: ResourceType.Project,
permission: Permission.Edit,
id: 'project-id',
}),
)
expect(list).toHaveBeenCalledWith('project-id')
})
it('returns saved languages and segments with asset read access', async () => {
const permission = vi.spyOn(authzService, 'hasPermission').mockResolvedValue(undefined)
const list = vi
+10
View File
@@ -12,6 +12,16 @@ import { z } from 'zod'
const route = new Hono<{ Variables: { user: User } }>()
.get('/transcription/languages', async (c) => c.json(await transcriptService.listLanguages()))
.get('/projects/:projectId/transcription-status', async (c) => {
const projectId = c.req.param('projectId')
await authzService.hasPermission({
user: c.get('user'),
permission: Permission.Edit,
type: ResourceType.Project,
id: projectId,
})
return c.json({ assetIds: await transcriptService.listActiveAssetIds(projectId) })
})
.get('/files/:fileId/transcripts', async (c) => {
const assetId = c.req.param('fileId')
await authzService.hasPermission({