Init commit

This commit is contained in:
ShreejitPanchal
2026-05-19 19:56:02 +08:00
commit 6601501eff
4047 changed files with 2185372 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
import { UserRight } from '@peertube/peertube-models'
import express from 'express'
import { param } from 'express-validator'
import { areValidationErrors, checkCanManageAccount, doesAccountHandleExist } from './shared/index.js'
export const accountHandleGetValidatorFactory = (options: {
checkCanManage: boolean
checkIsLocal: boolean
}) => {
const { checkCanManage, checkIsLocal } = options
return [
param('handle')
.exists(),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
if (areValidationErrors(req, res)) return
if (!await doesAccountHandleExist({ handle: req.params.handle, req, res, checkIsLocal, checkCanManage })) return
if (checkCanManage) {
const user = res.locals.oauth.token.User
if (!checkCanManageAccount({ account: res.locals.account, user, req, res, specialRight: UserRight.MANAGE_USERS })) {
return false
}
}
return next()
}
]
}