]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/helpers/custom-validators/video-blacklist.ts
Add ability to search on followers/following
[github/Chocobozzz/PeerTube.git] / server / helpers / custom-validators / video-blacklist.ts
CommitLineData
26b7305a
C
1import { Response } from 'express'
2import * as validator from 'validator'
3import { CONSTRAINTS_FIELDS } from '../../initializers'
4import { VideoBlacklistModel } from '../../models/video/video-blacklist'
5
6const VIDEO_BLACKLIST_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEO_BLACKLIST
7
8function isVideoBlacklistReasonValid (value: string) {
9 return value === null || validator.isLength(value, VIDEO_BLACKLIST_CONSTRAINTS_FIELDS.REASON)
10}
11
12async function isVideoBlacklistExist (videoId: number, res: Response) {
13 const videoBlacklist = await VideoBlacklistModel.loadByVideoId(videoId)
14
15 if (videoBlacklist === null) {
16 res.status(404)
17 .json({ error: 'Blacklisted video not found' })
18 .end()
19
20 return false
21 }
22
23 res.locals.videoBlacklist = videoBlacklist
24 return true
25}
26
27// ---------------------------------------------------------------------------
28
29export {
30 isVideoBlacklistReasonValid,
31 isVideoBlacklistExist
32}