Custom channel emoticons WIP (#130)

This commit is contained in:
John Livingston
2024-06-04 16:39:25 +02:00
parent 607a71b8cb
commit 688ab4f029
15 changed files with 469 additions and 48 deletions

View File

@ -12,13 +12,9 @@ import { isUserAdminOrModerator } from '../../helpers'
* Returns a middleware handler to get the channelInfos from the channel parameter.
* This is used in api related to channel configuration options.
* @param options Peertube server options
* @param publicPage If true, the page is considered public, and we don't test user rights.
* @returns middleware function
*/
function getCheckConfigurationChannelMiddleware (
options: RegisterServerOptions,
publicPage?: boolean
): RequestPromiseHandler {
function getCheckConfigurationChannelMiddleware (options: RegisterServerOptions): RequestPromiseHandler {
return async (req: Request, res: Response, next: NextFunction) => {
const logger = options.peertubeHelpers.logger
const channelId = req.params.channelId
@ -36,20 +32,18 @@ function getCheckConfigurationChannelMiddleware (
return
}
if (!publicPage) {
// To access this page, you must either be:
// - the channel owner,
// - an instance modo/admin
// - TODO: a channel chat moderator, as defined in this page.
if (channelInfos.ownerAccountId === currentUser.Account.id) {
logger.debug('Current user is the channel owner')
} else if (await isUserAdminOrModerator(options, res)) {
logger.debug('Current user is an instance moderator or admin')
} else {
logger.warn('Current user tries to access a channel for which he has no right.')
res.sendStatus(403)
return
}
// To access this page, you must either be:
// - the channel owner,
// - an instance modo/admin
// - TODO: a channel chat moderator, as defined in this page.
if (channelInfos.ownerAccountId === currentUser.Account.id) {
logger.debug('Current user is the channel owner')
} else if (await isUserAdminOrModerator(options, res)) {
logger.debug('Current user is an instance moderator or admin')
} else {
logger.warn('Current user tries to access a channel for which he has no right.')
res.sendStatus(403)
return
}
logger.debug('User can access the configuration channel api.')