aboutsummaryrefslogblamecommitdiffhomepage
path: root/server/helpers/custom-validators/video-ownership.ts
blob: 0e1c63bad7b9d8afb0d60aaa5ca839a0d17ddf45 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
                                  
                                              
                                                                                             
                                                                                  
 
                                                                                                                               
                                                          


               



                                                                   

              



                                      
import { Response } from 'express'
import { MUserId } from '@server/types/models'
import { MVideoChangeOwnershipFull } from '@server/types/models/video/video-change-ownership'
import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'

function checkUserCanTerminateOwnershipChange (user: MUserId, videoChangeOwnership: MVideoChangeOwnershipFull, res: Response) {
  if (videoChangeOwnership.NextOwner.userId === user.id) {
    return true
  }

  res.fail({
    status: HttpStatusCode.FORBIDDEN_403,
    message: 'Cannot terminate an ownership change of another user'
  })
  return false
}

export {
  checkUserCanTerminateOwnershipChange
}