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



                                           





                          

 


                                                                              
                
 
import { Response } from 'express'
import { AbuseModel } from '@server/models/abuse/abuse'
import { HttpStatusCode } from '@shared/models'

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
}