video-abuses.ts 631 B

123456789101112131415161718192021222324
  1. import { Response } from 'express'
  2. import { VideoAbuseModel } from '../../models/video/video-abuse'
  3. async function doesVideoAbuseExist (abuseIdArg: number | string, videoId: number, res: Response) {
  4. const abuseId = parseInt(abuseIdArg + '', 10)
  5. const videoAbuse = await VideoAbuseModel.loadByIdAndVideoId(abuseId, videoId)
  6. if (videoAbuse === null) {
  7. res.status(404)
  8. .json({ error: 'Video abuse not found' })
  9. .end()
  10. return false
  11. }
  12. res.locals.videoAbuse = videoAbuse
  13. return true
  14. }
  15. // ---------------------------------------------------------------------------
  16. export {
  17. doesVideoAbuseExist
  18. }