aboutsummaryrefslogblamecommitdiffhomepage
path: root/server/helpers/middlewares/video-abuses.ts
blob: 8a1d3d618296e38dece030bcf18282e2a9e21c1e (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 (abuseIdArg: number | string, videoId: number, res: Response) {
  const abuseId = parseInt(abuseIdArg + '', 10)
  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
}