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

                   
                                          





                          

 


                                                                              
                
 
import { Response } from 'express'
import { AbuseModel } from '../../models/abuse/abuse'

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

  if (!abuse) {
    res.status(404)
       .json({ error: 'Abuse not found' })

    return false
  }

  res.locals.abuse = abuse
  return true
}

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

export {
  doesAbuseExist
}