]>
Commit | Line | Data |
---|---|---|
453e83ea | 1 | import { Response } from 'express' |
d95d1559 | 2 | import { AbuseModel } from '../../models/abuse/abuse' |
2d53be02 | 3 | import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' |
453e83ea | 4 | |
57f6896f | 5 | async function doesAbuseExist (abuseId: number | string, res: Response) { |
94148c90 | 6 | const abuse = await AbuseModel.loadByIdWithReporter(parseInt(abuseId + '', 10)) |
d95d1559 | 7 | |
57f6896f | 8 | if (!abuse) { |
2d53be02 | 9 | res.status(HttpStatusCode.NOT_FOUND_404) |
310b5219 | 10 | .json({ error: 'Abuse not found' }) |
57f6896f C |
11 | |
12 | return false | |
13 | } | |
14 | ||
15 | res.locals.abuse = abuse | |
16 | return true | |
d95d1559 C |
17 | } |
18 | ||
453e83ea C |
19 | // --------------------------------------------------------------------------- |
20 | ||
21 | export { | |
7a4ea932 | 22 | doesAbuseExist |
453e83ea | 23 | } |