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