mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-05 19:42:24 +02:00
Add channel collaborators feature
This commit is contained in:
parent
94e55dfc6c
commit
b30ded66f6
192 changed files with 5534 additions and 2642 deletions
|
@ -1,20 +1,25 @@
|
|||
import { Response } from 'express'
|
||||
import { HttpStatusCode } from '@peertube/peertube-models'
|
||||
import { MUserId } from '@server/types/models/index.js'
|
||||
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'
|
||||
|
||||
function checkUserCanTerminateOwnershipChange (user: MUserId, videoChangeOwnership: MVideoChangeOwnershipFull, res: Response) {
|
||||
if (videoChangeOwnership.NextOwner.userId === user.id) {
|
||||
return true
|
||||
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
|
||||
}
|
||||
|
||||
res.fail({
|
||||
status: HttpStatusCode.FORBIDDEN_403,
|
||||
message: 'Cannot terminate an ownership change of another user'
|
||||
})
|
||||
return false
|
||||
}
|
||||
|
||||
export {
|
||||
checkUserCanTerminateOwnershipChange
|
||||
return true
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ import { REMOTE_SCHEME, WEBSERVER } from '../../initializers/constants.js'
|
|||
import { sanitizeHost } from '../core-utils.js'
|
||||
import { exists } from './misc.js'
|
||||
|
||||
function isWebfingerLocalResourceValid (value: string) {
|
||||
export function isWebfingerLocalResourceValid (value: string) {
|
||||
if (!exists(value)) return false
|
||||
if (value.startsWith('acct:') === false) return false
|
||||
|
||||
|
@ -13,9 +13,3 @@ function isWebfingerLocalResourceValid (value: string) {
|
|||
const host = actorParts[1]
|
||||
return sanitizeHost(host, REMOTE_SCHEME.HTTP) === WEBSERVER.HOST
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export {
|
||||
isWebfingerLocalResourceValid
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue