diff options
Diffstat (limited to 'server/helpers/middlewares')
-rw-r--r-- | server/helpers/middlewares/video-abuses.ts | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/server/helpers/middlewares/video-abuses.ts b/server/helpers/middlewares/video-abuses.ts index 8a1d3d618..7553a5eb3 100644 --- a/server/helpers/middlewares/video-abuses.ts +++ b/server/helpers/middlewares/video-abuses.ts | |||
@@ -1,9 +1,17 @@ | |||
1 | import { Response } from 'express' | 1 | import { Response } from 'express' |
2 | import { VideoAbuseModel } from '../../models/video/video-abuse' | 2 | import { VideoAbuseModel } from '../../models/video/video-abuse' |
3 | import { fetchVideo } from '../video' | ||
3 | 4 | ||
4 | async function doesVideoAbuseExist (abuseIdArg: number | string, videoId: number, res: Response) { | 5 | async function doesVideoAbuseExist (abuseIdArg: number | string, videoUUID: string, res: Response) { |
5 | const abuseId = parseInt(abuseIdArg + '', 10) | 6 | const abuseId = parseInt(abuseIdArg + '', 10) |
6 | const videoAbuse = await VideoAbuseModel.loadByIdAndVideoId(abuseId, videoId) | 7 | let videoAbuse = await VideoAbuseModel.loadByIdAndVideoId(abuseId, null, videoUUID) |
8 | |||
9 | if (!videoAbuse) { | ||
10 | const userId = res.locals.oauth ? res.locals.oauth.token.User.id : undefined | ||
11 | const video = await fetchVideo(videoUUID, 'all', userId) | ||
12 | |||
13 | if (video) videoAbuse = await VideoAbuseModel.loadByIdAndVideoId(abuseId, video.id) | ||
14 | } | ||
7 | 15 | ||
8 | if (videoAbuse === null) { | 16 | if (videoAbuse === null) { |
9 | res.status(404) | 17 | res.status(404) |