aboutsummaryrefslogblamecommitdiffhomepage
path: root/server/helpers/middlewares/abuses.ts
blob: f0b1caba84e55f8f2a212108910fb27bfd7cdc4d (plain) (tree)
1
2
3
4
5
6
7
8
                                  
                                                     
                                                                                  
 
                                                                         
                                                                                 
 
               



                                           





                          

 


                                                                              
                
 
import { Response } from 'express'
import { AbuseModel } from '../../models/abuse/abuse'
import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'

async function doesAbuseExist (abuseId: number | string, res: Response) {
  const abuse = await AbuseModel.loadByIdWithReporter(parseInt(abuseId + '', 10))

  if (!abuse) {
    res.fail({
      status: HttpStatusCode.NOT_FOUND_404,
      message: 'Abuse not found'
    })

    return false
  }

  res.locals.abuse = abuse
  return true
}

// ---------------------------------------------------------------------------

export {
  doesAbuseExist
}