aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/middlewares/video-channels.ts
blob: 1b573ca37e7ae2bf0dff4956af95ecb76ac9b2d6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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
}