Replacing old settings by chat-type.
This commit is contained in:
@ -6,6 +6,7 @@ import { prosodyCheckUserPassword, prosodyRegisterUser, prosodyUserRegistered }
|
||||
import { getUserNickname } from '../helpers'
|
||||
import { Affiliations, getVideoAffiliations } from '../prosody/config/affiliations'
|
||||
import { getProsodyDomain } from '../prosody/config/domain'
|
||||
import type { ChatType } from '../../../shared/lib/types'
|
||||
|
||||
// See here for description: https://modules.prosody.im/mod_muc_http_defaults.html
|
||||
interface RoomDefaults {
|
||||
@ -46,13 +47,13 @@ async function initApiRouter (options: RegisterServerOptions): Promise<Router> {
|
||||
}
|
||||
// check settings (chat enabled for this video?)
|
||||
const settings = await options.settingsManager.getSettings([
|
||||
'chat-use-prosody',
|
||||
'chat-type',
|
||||
'chat-only-locals',
|
||||
'chat-all-lives',
|
||||
'chat-all-non-lives',
|
||||
'chat-videos-list'
|
||||
])
|
||||
if (!settings['chat-use-prosody']) {
|
||||
if (settings['chat-type'] !== ('builtin-prosody' as ChatType)) {
|
||||
logger.warn('Prosody chat is not active')
|
||||
res.sendStatus(403)
|
||||
return
|
||||
@ -121,13 +122,13 @@ async function initApiRouter (options: RegisterServerOptions): Promise<Router> {
|
||||
router.get('/user/check_password', asyncMiddleware(
|
||||
async (req: Request, res: Response, _next: NextFunction) => {
|
||||
const settings = await options.settingsManager.getSettings([
|
||||
'chat-use-prosody',
|
||||
'chat-type',
|
||||
'chat-only-locals',
|
||||
'chat-all-lives',
|
||||
'chat-all-non-lives',
|
||||
'chat-videos-list'
|
||||
])
|
||||
if (!settings['chat-use-prosody']) {
|
||||
if (settings['chat-type'] !== ('builtin-prosody' as ChatType)) {
|
||||
logger.warn('Prosody chat is not active')
|
||||
res.status(200).send('false')
|
||||
return
|
||||
@ -152,13 +153,13 @@ async function initApiRouter (options: RegisterServerOptions): Promise<Router> {
|
||||
router.get('/user/user_exists', asyncMiddleware(
|
||||
async (req: Request, res: Response, _next: NextFunction) => {
|
||||
const settings = await options.settingsManager.getSettings([
|
||||
'chat-use-prosody',
|
||||
'chat-type',
|
||||
'chat-only-locals',
|
||||
'chat-all-lives',
|
||||
'chat-all-non-lives',
|
||||
'chat-videos-list'
|
||||
])
|
||||
if (!settings['chat-use-prosody']) {
|
||||
if (settings['chat-type'] !== ('builtin-prosody' as ChatType)) {
|
||||
logger.warn('Prosody chat is not active')
|
||||
res.status(200).send('false')
|
||||
return
|
||||
|
@ -1,5 +1,6 @@
|
||||
import type { Router, RequestHandler, Request, Response, NextFunction } from 'express'
|
||||
import type { ProxyOptions } from 'express-http-proxy'
|
||||
import type { ChatType } from '../../../shared/lib/types'
|
||||
import { getBaseRouterRoute, getBaseStaticRoute } from '../helpers'
|
||||
import { asyncMiddleware } from '../middlewares/async'
|
||||
import { getProsodyDomain } from '../prosody/config/domain'
|
||||
@ -27,9 +28,10 @@ async function initWebchatRouter (options: RegisterServerOptions): Promise<Route
|
||||
res.removeHeader('X-Frame-Options') // this route can be opened in an iframe
|
||||
|
||||
const settings = await settingsManager.getSettings([
|
||||
'chat-use-prosody', 'chat-use-builtin', 'chat-room', 'chat-server',
|
||||
'chat-type', 'chat-room', 'chat-server',
|
||||
'chat-bosh-uri', 'chat-ws-uri'
|
||||
])
|
||||
const chatType: ChatType = (settings['chat-type'] ?? 'disabled') as ChatType
|
||||
|
||||
let server: string
|
||||
let room: string
|
||||
@ -37,7 +39,7 @@ async function initWebchatRouter (options: RegisterServerOptions): Promise<Route
|
||||
let wsUri: string
|
||||
let authenticationUrl: string = ''
|
||||
let advancedControls: boolean = false
|
||||
if (settings['chat-use-prosody']) {
|
||||
if (chatType === 'builtin-prosody') {
|
||||
const prosodyDomain = await getProsodyDomain(options)
|
||||
server = 'anon.' + prosodyDomain
|
||||
room = '{{VIDEO_UUID}}@room.' + prosodyDomain
|
||||
@ -47,7 +49,7 @@ async function initWebchatRouter (options: RegisterServerOptions): Promise<Route
|
||||
getBaseRouterRoute(options) +
|
||||
'api/auth'
|
||||
advancedControls = true
|
||||
} else if (settings['chat-use-builtin']) {
|
||||
} else if (chatType === 'builtin-converse') {
|
||||
if (!settings['chat-server']) {
|
||||
throw new Error('Missing chat-server settings.')
|
||||
}
|
||||
|
Reference in New Issue
Block a user