]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/helpers/custom-validators/video-ownership.ts
Bumped to version v5.2.1
[github/Chocobozzz/PeerTube.git] / server / helpers / custom-validators / video-ownership.ts
CommitLineData
74d63469 1import { Response } from 'express'
26d6bf65 2import { MUserId } from '@server/types/models'
10363c74 3import { MVideoChangeOwnershipFull } from '@server/types/models/video/video-change-ownership'
c0e8b12e 4import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
74d63469 5
10363c74 6function checkUserCanTerminateOwnershipChange (user: MUserId, videoChangeOwnership: MVideoChangeOwnershipFull, res: Response) {
f41d6aac 7 if (videoChangeOwnership.NextOwner.userId === user.id) {
74d63469
GR
8 return true
9 }
10
76148b27
RK
11 res.fail({
12 status: HttpStatusCode.FORBIDDEN_403,
13 message: 'Cannot terminate an ownership change of another user'
14 })
74d63469
GR
15 return false
16}
10363c74
C
17
18export {
19 checkUserCanTerminateOwnershipChange
20}