aboutsummaryrefslogblamecommitdiffhomepage
path: root/server/helpers/middlewares/video-blacklists.ts
blob: eda1324d3f350707eff6e4d55fd5025fd923f059 (plain) (tree)
1
2
3
4
5
6
7
8
9

                                                                        
                                                                                  




                                                                         
                                            














                                                                              
import { Response } from 'express'
import { VideoBlacklistModel } from '../../models/video/video-blacklist'
import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'

async function doesVideoBlacklistExist (videoId: number, res: Response) {
  const videoBlacklist = await VideoBlacklistModel.loadByVideoId(videoId)

  if (videoBlacklist === null) {
    res.status(HttpStatusCode.NOT_FOUND_404)
       .json({ error: 'Blacklisted video not found' })
       .end()

    return false
  }

  res.locals.videoBlacklist = videoBlacklist
  return true
}

// ---------------------------------------------------------------------------

export {
  doesVideoBlacklistExist
}