]>
Commit | Line | Data |
---|---|---|
453e83ea | 1 | import { Response } from 'express' |
d95d1559 | 2 | import { AbuseModel } from '../../models/abuse/abuse' |
68d19a0a | 3 | import { fetchVideo } from '../video' |
3e753302 | 4 | |
d95d1559 | 5 | // FIXME: deprecated in 2.3. Remove this function |
68d19a0a | 6 | async function doesVideoAbuseExist (abuseIdArg: number | string, videoUUID: string, res: Response) { |
d5d9b6d7 | 7 | const abuseId = parseInt(abuseIdArg + '', 10) |
d95d1559 | 8 | let abuse = await AbuseModel.loadByIdAndVideoId(abuseId, null, videoUUID) |
68d19a0a | 9 | |
d95d1559 | 10 | if (!abuse) { |
0251197e | 11 | const userId = res.locals.oauth?.token.User.id |
68d19a0a RK |
12 | const video = await fetchVideo(videoUUID, 'all', userId) |
13 | ||
d95d1559 | 14 | if (video) abuse = await AbuseModel.loadByIdAndVideoId(abuseId, video.id) |
68d19a0a | 15 | } |
3e753302 | 16 | |
d95d1559 | 17 | if (abuse === null) { |
3e753302 | 18 | res.status(404) |
453e83ea | 19 | .json({ error: 'Video abuse not found' }) |
3e753302 C |
20 | .end() |
21 | ||
22 | return false | |
23 | } | |
24 | ||
d95d1559 | 25 | res.locals.abuse = abuse |
3e753302 C |
26 | return true |
27 | } | |
453e83ea | 28 | |
d95d1559 C |
29 | async function doesAbuseExist (abuseIdArg: number | string, videoUUID: string, res: Response) { |
30 | ||
31 | } | |
32 | ||
453e83ea C |
33 | // --------------------------------------------------------------------------- |
34 | ||
35 | export { | |
d95d1559 | 36 | doesAbuseExist, |
453e83ea C |
37 | doesVideoAbuseExist |
38 | } |