Do not run transcription/transcoding on lives

pull/6527/head
Chocobozzz 2024-07-01 11:15:09 +02:00
parent 45d22afca6
commit b45ed3c05a
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
4 changed files with 23 additions and 11 deletions

View File

@ -244,10 +244,6 @@ export class Video implements VideoServerModel {
this.isUpdatableBy(user)
}
canGenerateTranscription (user: AuthUser, transcriptionEnabled: boolean) {
return transcriptionEnabled && this.isLocal && user.hasRight(UserRight.UPDATE_ANY_VIDEO)
}
// ---------------------------------------------------------------------------
isOwner (user: AuthUser) {
@ -278,13 +274,15 @@ export class Video implements VideoServerModel {
}
canRunTranscoding (user: AuthUser) {
return this.canRunForcedTranscoding(user)
return this.isLocal && !this.isLive && user?.hasRight(UserRight.RUN_VIDEO_TRANSCODING)
}
canRunForcedTranscoding (user: AuthUser) {
return this.isLocal && user?.hasRight(UserRight.RUN_VIDEO_TRANSCODING)
canGenerateTranscription (user: AuthUser, transcriptionEnabled: boolean) {
return transcriptionEnabled && this.isLocal && !this.isLive && user.hasRight(UserRight.UPDATE_ANY_VIDEO)
}
// ---------------------------------------------------------------------------
hasHLS () {
return this.streamingPlaylists?.some(p => p.type === VideoStreamingPlaylistType.HLS)
}

View File

@ -234,8 +234,8 @@ export class VideoActionsDropdownComponent implements OnChanges {
return this.video.canRemoveFiles(this.user)
}
canRunForcedTranscoding () {
return this.video.canRunForcedTranscoding(this.user)
canRunTranscoding () {
return this.video.canRunTranscoding(this.user)
}
/* Action handlers */
@ -462,13 +462,13 @@ export class VideoActionsDropdownComponent implements OnChanges {
{
label: $localize`Run HLS transcoding`,
handler: ({ video }) => this.runTranscoding(video, 'hls'),
isDisplayed: () => this.displayOptions.transcoding && this.canRunForcedTranscoding(),
isDisplayed: () => this.displayOptions.transcoding && this.canRunTranscoding(),
iconName: 'cog'
},
{
label: $localize`Run Web Video transcoding`,
handler: ({ video }) => this.runTranscoding(video, 'web-video'),
isDisplayed: () => this.displayOptions.transcoding && this.canRunForcedTranscoding(),
isDisplayed: () => this.displayOptions.transcoding && this.canRunTranscoding(),
iconName: 'cog'
},
{

View File

@ -74,6 +74,13 @@ export const generateVideoCaptionValidator = [
})
}
if (video.isLive) {
return res.fail({
status: HttpStatusCode.BAD_REQUEST_400,
message: 'Cannot run transcription job on a live'
})
}
// Check if the user who did the request is able to update the video
const user = res.locals.oauth.token.User
if (!checkUserCanManageVideo(user, video, UserRight.UPDATE_ANY_VIDEO, res)) return

View File

@ -31,6 +31,13 @@ const createTranscodingValidator = [
})
}
if (video.isLive) {
return res.fail({
status: HttpStatusCode.BAD_REQUEST_400,
message: 'Cannot run transcoding job on a live'
})
}
if (CONFIG.TRANSCODING.ENABLED !== true) {
return res.fail({
status: HttpStatusCode.BAD_REQUEST_400,