Builtin Prosody: allow moderation operations.

This commit is contained in:
John Livingston 2021-05-05 17:20:06 +02:00
parent 6b77c3585d
commit e5d5da4d07
3 changed files with 24 additions and 10 deletions

View File

@ -78,6 +78,7 @@ interface InitConverseParams {
boshServiceUrl: string boshServiceUrl: string
websocketServiceUrl: string websocketServiceUrl: string
authenticationUrl: string authenticationUrl: string
advancedControls: 'true' | 'false'
} }
window.initConverse = async function initConverse ({ window.initConverse = async function initConverse ({
jid, jid,
@ -85,8 +86,10 @@ window.initConverse = async function initConverse ({
room, room,
boshServiceUrl, boshServiceUrl,
websocketServiceUrl, websocketServiceUrl,
authenticationUrl authenticationUrl,
advancedControls
}: InitConverseParams) { }: InitConverseParams) {
const isInIframe = inIframe()
const params: any = { const params: any = {
assets_path: assetsPath, assets_path: assetsPath,
@ -103,18 +106,12 @@ window.initConverse = async function initConverse ({
room room
], ],
singleton: true, singleton: true,
auto_focus: false, auto_focus: isInIframe,
hide_muc_participants: inIframe(), hide_muc_participants: isInIframe,
keepalive: true, keepalive: true,
play_sounds: false, play_sounds: false,
muc_mention_autocomplete_min_chars: 3, muc_mention_autocomplete_min_chars: 3,
muc_mention_autocomplete_filter: 'contains', muc_mention_autocomplete_filter: 'contains',
modtools_disable_assign: true,
muc_disable_slash_commands: [
'admin', 'ban', 'clear', 'deop', 'destroy', 'kick',
'member', 'modtools', 'mute', 'op', 'owner', 'register',
'revoke', 'subject', 'topic', 'voice'
],
muc_instant_rooms: true, muc_instant_rooms: true,
show_client_info: false, show_client_info: false,
allow_adhoc_commands: false, allow_adhoc_commands: false,
@ -143,5 +140,18 @@ window.initConverse = async function initConverse ({
} }
} }
if (!advancedControls) {
// These params are for externals XMPP servers.
// NB: because we dont know if external servers have authentication mecanism,
// we disable all moderation functionnality.
// This is also done for backward compatibility with older installations.
params.muc_disable_slash_commands = [
'admin', 'ban', 'clear', 'deop', 'destroy', 'kick',
'member', 'modtools', 'mute', 'op', 'owner', 'register',
'revoke', 'subject', 'topic', 'voice'
]
params.modtools_disable_assign = true
}
window.converse.initialize(params) window.converse.initialize(params)
} }

View File

@ -24,7 +24,8 @@
room: '{{ROOM}}', room: '{{ROOM}}',
boshServiceUrl: '{{BOSH_SERVICE_URL}}', boshServiceUrl: '{{BOSH_SERVICE_URL}}',
websocketServiceUrl: '{{WS_SERVICE_URL}}', websocketServiceUrl: '{{WS_SERVICE_URL}}',
authenticationUrl: '{{AUTHENTICATION_URL}}' authenticationUrl: '{{AUTHENTICATION_URL}}',
advancedControls: '{{ADVANCEDCONTROLS}}'
}) })
</script> </script>
</body> </body>

View File

@ -33,6 +33,7 @@ async function initWebchatRouter (options: RegisterServerOptions): Promise<Route
let boshUri: string let boshUri: string
let wsUri: string let wsUri: string
let authenticationUrl: string = '' let authenticationUrl: string = ''
let advancedControls: boolean = false
if (settings['chat-use-prosody']) { if (settings['chat-use-prosody']) {
server = 'anon.localhost' server = 'anon.localhost'
room = '{{VIDEO_UUID}}@room.localhost' room = '{{VIDEO_UUID}}@room.localhost'
@ -41,6 +42,7 @@ async function initWebchatRouter (options: RegisterServerOptions): Promise<Route
authenticationUrl = options.peertubeHelpers.config.getWebserverUrl() + authenticationUrl = options.peertubeHelpers.config.getWebserverUrl() +
getBaseRouter() + getBaseRouter() +
'api/auth' 'api/auth'
advancedControls = true
} else if (settings['chat-use-builtin']) { } else if (settings['chat-use-builtin']) {
if (!settings['chat-server']) { if (!settings['chat-server']) {
throw new Error('Missing chat-server settings.') throw new Error('Missing chat-server settings.')
@ -75,6 +77,7 @@ async function initWebchatRouter (options: RegisterServerOptions): Promise<Route
page = page.replace(/{{BOSH_SERVICE_URL}}/g, boshUri) page = page.replace(/{{BOSH_SERVICE_URL}}/g, boshUri)
page = page.replace(/{{WS_SERVICE_URL}}/g, wsUri) page = page.replace(/{{WS_SERVICE_URL}}/g, wsUri)
page = page.replace(/{{AUTHENTICATION_URL}}/g, authenticationUrl) page = page.replace(/{{AUTHENTICATION_URL}}/g, authenticationUrl)
page = page.replace(/{{ADVANCEDCONTROLS}}/g, advancedControls ? 'true' : 'false')
res.status(200) res.status(200)
res.type('html') res.type('html')