1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-03 01:39:37 +02:00
Peertube/server/core/helpers/custom-validators/video-ownership.ts
2025-09-23 14:10:56 +02:00

25 lines
911 B
TypeScript

import { HttpStatusCode, UserRight } from '@peertube/peertube-models'
import { checkCanManageAccount } from '@server/middlewares/validators/shared/users.js'
import { MUserAccountId } from '@server/types/models/index.js'
import { MVideoChangeOwnershipFull } from '@server/types/models/video/video-change-ownership.js'
import { Request, Response } from 'express'
export function checkCanTerminateOwnershipChange (options: {
user: MUserAccountId
videoChangeOwnership: MVideoChangeOwnershipFull
req: Request
res: Response
}) {
const { user, videoChangeOwnership, req, res } = options
if (!checkCanManageAccount({ user, account: videoChangeOwnership.NextOwner, req, res: null, specialRight: UserRight.MANAGE_USERS })) {
res.fail({
status: HttpStatusCode.FORBIDDEN_403,
message: req.t('Cannot terminate an ownership change of another user')
})
return false
}
return true
}