1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-05 10:49:28 +02:00

Add blacklist reason field

This commit is contained in:
Chocobozzz 2018-08-13 16:57:13 +02:00
parent efc9e8450a
commit 26b7305a23
No known key found for this signature in database
GPG key ID: 583A612D890159BE
35 changed files with 689 additions and 163 deletions

View file

@ -0,0 +1,32 @@
import { Response } from 'express'
import * as validator from 'validator'
import { CONSTRAINTS_FIELDS } from '../../initializers'
import { VideoBlacklistModel } from '../../models/video/video-blacklist'
const VIDEO_BLACKLIST_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEO_BLACKLIST
function isVideoBlacklistReasonValid (value: string) {
return value === null || validator.isLength(value, VIDEO_BLACKLIST_CONSTRAINTS_FIELDS.REASON)
}
async function isVideoBlacklistExist (videoId: number, res: Response) {
const videoBlacklist = await VideoBlacklistModel.loadByVideoId(videoId)
if (videoBlacklist === null) {
res.status(404)
.json({ error: 'Blacklisted video not found' })
.end()
return false
}
res.locals.videoBlacklist = videoBlacklist
return true
}
// ---------------------------------------------------------------------------
export {
isVideoBlacklistReasonValid,
isVideoBlacklistExist
}