PeerTube/server/middlewares/validators/shared/video-blacklists.ts

25 lines
657 B
TypeScript
Raw Normal View History

2019-07-23 10:40:39 +02:00
import { Response } from 'express'
import { VideoBlacklistModel } from '@server/models/video/video-blacklist'
import { HttpStatusCode } from '@shared/core-utils'
2019-07-23 10:40:39 +02:00
async function doesVideoBlacklistExist (videoId: number, res: Response) {
const videoBlacklist = await VideoBlacklistModel.loadByVideoId(videoId)
if (videoBlacklist === null) {
res.fail({
status: HttpStatusCode.NOT_FOUND_404,
message: 'Blacklisted video not found'
})
2019-07-23 10:40:39 +02:00
return false
}
res.locals.videoBlacklist = videoBlacklist
return true
}
// ---------------------------------------------------------------------------
export {
doesVideoBlacklistExist
}