1
0
Fork 0

Prevent error on highlighted thread

This commit is contained in:
Chocobozzz 2022-07-29 10:32:56 +02:00
parent 37b1d97f22
commit 5a9a56b78f
No known key found for this signature in database
GPG key ID: 583A612D890159BE
4 changed files with 27 additions and 5 deletions

View file

@ -1,7 +1,7 @@
import express from 'express'
import { VideoCommentModel } from '@server/models/video/video-comment'
import { MVideoId } from '@server/types/models'
import { HttpStatusCode } from '@shared/models'
import { HttpStatusCode, ServerErrorCode } from '@shared/models'
async function doesVideoCommentThreadExist (idArg: number | string, video: MVideoId, res: express.Response) {
const id = parseInt(idArg + '', 10)
@ -16,7 +16,10 @@ async function doesVideoCommentThreadExist (idArg: number | string, video: MVide
}
if (videoComment.videoId !== video.id) {
res.fail({ message: 'Video comment is not associated to this video.' })
res.fail({
type: ServerErrorCode.COMMENT_NOT_ASSOCIATED_TO_VIDEO,
message: 'Video comment is not associated to this video.'
})
return false
}
@ -42,7 +45,10 @@ async function doesVideoCommentExist (idArg: number | string, video: MVideoId, r
}
if (videoComment.videoId !== video.id) {
res.fail({ message: 'Video comment is not associated to this video.' })
res.fail({
type: ServerErrorCode.COMMENT_NOT_ASSOCIATED_TO_VIDEO,
message: 'Video comment is not associated to this video.'
})
return false
}