2019-08-15 05:53:26 -04:00
|
|
|
import { Response } from 'express'
|
2021-06-03 11:33:44 -04:00
|
|
|
import { AbuseModel } from '@server/models/abuse/abuse'
|
2021-07-16 04:42:24 -04:00
|
|
|
import { HttpStatusCode } from '@shared/models'
|
2019-08-15 05:53:26 -04:00
|
|
|
|
2020-07-07 04:57:04 -04:00
|
|
|
async function doesAbuseExist (abuseId: number | string, res: Response) {
|
2020-07-27 05:40:30 -04:00
|
|
|
const abuse = await AbuseModel.loadByIdWithReporter(parseInt(abuseId + '', 10))
|
2020-07-01 10:05:30 -04:00
|
|
|
|
2020-07-07 04:57:04 -04:00
|
|
|
if (!abuse) {
|
2021-05-31 19:36:53 -04:00
|
|
|
res.fail({
|
|
|
|
status: HttpStatusCode.NOT_FOUND_404,
|
|
|
|
message: 'Abuse not found'
|
|
|
|
})
|
2020-07-07 04:57:04 -04:00
|
|
|
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
res.locals.abuse = abuse
|
|
|
|
return true
|
2020-07-01 10:05:30 -04:00
|
|
|
}
|
|
|
|
|
2019-08-15 05:53:26 -04:00
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
export {
|
2020-11-10 08:41:20 -05:00
|
|
|
doesAbuseExist
|
2019-08-15 05:53:26 -04:00
|
|
|
}
|