Renaming 'moderation' pages to 'configuration'.
This commit is contained in:
@ -2,16 +2,16 @@ import type { RegisterServerOptions } from '@peertube/peertube-types'
|
||||
import type { Router, Request, Response, NextFunction } from 'express'
|
||||
import type { ChannelInfos } from '../../../../shared/lib/types'
|
||||
import { asyncMiddleware } from '../../middlewares/async'
|
||||
import { getCheckModerationChannelMiddleware } from '../../middlewares/moderation/channel'
|
||||
import { getChannelModerationOptions, storeChannelModerationOptions } from '../../moderation/channel/storage'
|
||||
import { sanitizeChannelModerationOptions } from '../../moderation/channel/sanitize'
|
||||
import { getCheckConfigurationChannelMiddleware } from '../../middlewares/configuration/channel'
|
||||
import { getChannelConfigurationOptions, storeChannelConfigurationOptions } from '../../configuration/channel/storage'
|
||||
import { sanitizeChannelConfigurationOptions } from '../../configuration/channel/sanitize'
|
||||
|
||||
async function initModerationApiRouter (options: RegisterServerOptions): Promise<Router> {
|
||||
async function initConfigurationApiRouter (options: RegisterServerOptions): Promise<Router> {
|
||||
const router = options.getRouter()
|
||||
const logger = options.peertubeHelpers.logger
|
||||
|
||||
router.get('/channel/:channelId', asyncMiddleware([
|
||||
getCheckModerationChannelMiddleware(options),
|
||||
getCheckConfigurationChannelMiddleware(options),
|
||||
async (req: Request, res: Response, _next: NextFunction): Promise<void> => {
|
||||
if (!res.locals.channelInfos) {
|
||||
logger.error('Missing channelInfos in res.locals, should not happen')
|
||||
@ -20,14 +20,14 @@ async function initModerationApiRouter (options: RegisterServerOptions): Promise
|
||||
}
|
||||
const channelInfos = res.locals.channelInfos as ChannelInfos
|
||||
|
||||
const result = await getChannelModerationOptions(options, channelInfos)
|
||||
const result = await getChannelConfigurationOptions(options, channelInfos)
|
||||
res.status(200)
|
||||
res.json(result)
|
||||
}
|
||||
]))
|
||||
|
||||
router.post('/channel/:channelId', asyncMiddleware([
|
||||
getCheckModerationChannelMiddleware(options),
|
||||
getCheckConfigurationChannelMiddleware(options),
|
||||
async (req: Request, res: Response, _next: NextFunction): Promise<void> => {
|
||||
if (!res.locals.channelInfos) {
|
||||
logger.error('Missing channelInfos in res.locals, should not happen')
|
||||
@ -35,11 +35,11 @@ async function initModerationApiRouter (options: RegisterServerOptions): Promise
|
||||
return
|
||||
}
|
||||
const channelInfos = res.locals.channelInfos as ChannelInfos
|
||||
logger.debug('Trying to save ChannelModerationOptions')
|
||||
logger.debug('Trying to save ChannelConfigurationOptions')
|
||||
|
||||
let moderation
|
||||
let configuration
|
||||
try {
|
||||
moderation = await sanitizeChannelModerationOptions(options, channelInfos, req.body)
|
||||
configuration = await sanitizeChannelConfigurationOptions(options, channelInfos, req.body)
|
||||
} catch (err) {
|
||||
logger.warn(err)
|
||||
res.sendStatus(400)
|
||||
@ -49,9 +49,9 @@ async function initModerationApiRouter (options: RegisterServerOptions): Promise
|
||||
logger.debug('Data seems ok, storing them.')
|
||||
const result = {
|
||||
channel: channelInfos,
|
||||
moderation
|
||||
configuration
|
||||
}
|
||||
await storeChannelModerationOptions(options, result)
|
||||
await storeChannelConfigurationOptions(options, result)
|
||||
res.status(200)
|
||||
res.json(result)
|
||||
}
|
||||
@ -61,5 +61,5 @@ async function initModerationApiRouter (options: RegisterServerOptions): Promise
|
||||
}
|
||||
|
||||
export {
|
||||
initModerationApiRouter
|
||||
initConfigurationApiRouter
|
||||
}
|
Reference in New Issue
Block a user