2019-08-15 04:53:26 -05:00
|
|
|
import { Response } from 'express'
|
2020-07-01 09:05:30 -05:00
|
|
|
import { AbuseModel } from '../../models/abuse/abuse'
|
2019-08-15 04:53:26 -05:00
|
|
|
|
2020-07-07 03:57:04 -05:00
|
|
|
async function doesAbuseExist (abuseId: number | string, res: Response) {
|
2020-07-27 04:40:30 -05:00
|
|
|
const abuse = await AbuseModel.loadByIdWithReporter(parseInt(abuseId + '', 10))
|
2020-07-01 09:05:30 -05:00
|
|
|
|
2020-07-07 03:57:04 -05:00
|
|
|
if (!abuse) {
|
|
|
|
res.status(404)
|
2020-07-08 08:51:46 -05:00
|
|
|
.json({ error: 'Abuse not found' })
|
2020-07-07 03:57:04 -05:00
|
|
|
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
res.locals.abuse = abuse
|
|
|
|
return true
|
2020-07-01 09:05:30 -05:00
|
|
|
}
|
|
|
|
|
2019-08-15 04:53:26 -05:00
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
export {
|
2020-11-10 07:41:20 -06:00
|
|
|
doesAbuseExist
|
2019-08-15 04:53:26 -05:00
|
|
|
}
|