29 lines
856 B
TypeScript
29 lines
856 B
TypeScript
import { getTencentBrowserSessionReviewScreenshotPath } from '../session/session.js'
|
|
import { createHttpError } from '../../utils/http.js'
|
|
import { getRequiredTask } from './admin-task-read-helpers.js'
|
|
|
|
import type {
|
|
AdminEntityIdInput,
|
|
AdminViewerSessionInput,
|
|
} from '../../types/admin-read-inputs.js'
|
|
|
|
export async function getAdminTaskScreenshotPathWithTencentFallback(
|
|
taskId: AdminEntityIdInput,
|
|
_session: AdminViewerSessionInput | null = null,
|
|
): Promise<string> {
|
|
const task = await getRequiredTask(taskId)
|
|
|
|
if (task.screenshot_path) {
|
|
return task.screenshot_path
|
|
}
|
|
|
|
if (task.browser_session_id) {
|
|
return getTencentBrowserSessionReviewScreenshotPath(task.browser_session_id)
|
|
}
|
|
|
|
throw createHttpError('当前任务还没有可查看截图', {
|
|
statusCode: 404,
|
|
errorCode: 'admin_task_screenshot_not_found',
|
|
})
|
|
}
|