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

                                                                
 

                                                                                      
 
                            
                   
                                                




                
                                    

             





                                                                              
import { Response } from 'express'
import { VideoAbuseModel } from '../../models/video/video-abuse'

async function doesVideoAbuseExist (abuseId: number, videoId: number, res: Response) {
  const videoAbuse = await VideoAbuseModel.loadByIdAndVideoId(abuseId, videoId)

  if (videoAbuse === null) {
    res.status(404)
       .json({ error: 'Video abuse not found' })
       .end()

    return false
  }

  res.locals.videoAbuse = videoAbuse
  return true
}

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

export {
  doesVideoAbuseExist
}