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