2019-08-15 11:53:26 +02:00
|
|
|
import { Response } from 'express'
|
2020-07-01 16:05:30 +02:00
|
|
|
import { AbuseModel } from '../../models/abuse/abuse'
|
2020-12-07 14:32:36 +01:00
|
|
|
import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
|
2019-08-15 11:53:26 +02:00
|
|
|
|
2020-07-07 10:57:04 +02:00
|
|
|
async function doesAbuseExist (abuseId: number | string, res: Response) {
|
2020-07-27 11:40:30 +02:00
|
|
|
const abuse = await AbuseModel.loadByIdWithReporter(parseInt(abuseId + '', 10))
|
2020-07-01 16:05:30 +02:00
|
|
|
|
2020-07-07 10:57:04 +02:00
|
|
|
if (!abuse) {
|
2020-12-07 14:32:36 +01:00
|
|
|
res.status(HttpStatusCode.NOT_FOUND_404)
|
2020-07-08 15:51:46 +02:00
|
|
|
.json({ error: 'Abuse not found' })
|
2020-07-07 10:57:04 +02:00
|
|
|
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
res.locals.abuse = abuse
|
|
|
|
return true
|
2020-07-01 16:05:30 +02:00
|
|
|
}
|
|
|
|
|
2019-08-15 11:53:26 +02:00
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
export {
|
2020-11-10 14:41:20 +01:00
|
|
|
doesAbuseExist
|
2019-08-15 11:53:26 +02:00
|
|
|
}
|