Refactoring and simplification (#122)
This commit is contained in:
parent
a1bb4788c4
commit
3f47c3c65a
@ -87,7 +87,6 @@ interface InitConverseParams {
|
||||
boshServiceUrl: string
|
||||
websocketServiceUrl: string
|
||||
authenticationUrl: string
|
||||
advancedControls: boolean
|
||||
autoViewerMode: boolean
|
||||
forceReadonly: boolean | 'noscroll'
|
||||
noScroll: boolean
|
||||
@ -101,7 +100,6 @@ window.initConverse = async function initConverse ({
|
||||
boshServiceUrl,
|
||||
websocketServiceUrl,
|
||||
authenticationUrl,
|
||||
advancedControls,
|
||||
autoViewerMode,
|
||||
forceReadonly,
|
||||
theme,
|
||||
@ -177,15 +175,18 @@ window.initConverse = async function initConverse ({
|
||||
persistent_store: 'sessionStorage',
|
||||
show_images_inline: false, // for security reason, and to avoid bugs when image is larger that iframe
|
||||
render_media: false, // for security reason, and to avoid bugs when image is larger that iframe
|
||||
whitelisted_plugins: ['livechatWindowTitlePlugin', 'livechatViewerModePlugin', 'livechatDisconnectOnUnloadPlugin']
|
||||
whitelisted_plugins: ['livechatWindowTitlePlugin', 'livechatViewerModePlugin', 'livechatDisconnectOnUnloadPlugin'],
|
||||
show_retraction_warning: false // No need to use this warning (except if we open to external clients?)
|
||||
}
|
||||
|
||||
// TODO: params.clear_messages_on_reconnection = true when muc_mam will be available.
|
||||
|
||||
let isAuthenticated: boolean = false
|
||||
if (authenticationUrl !== '') {
|
||||
// We are in builtin-prosody mode.
|
||||
// So the user will never se the «trusted browser» checkbox.
|
||||
if (authenticationUrl === '') {
|
||||
throw new Error('Missing authenticationUrl')
|
||||
}
|
||||
|
||||
// The user will never se the «trusted browser» checkbox (that allows to save credentials).
|
||||
// So we have to disable it
|
||||
// (and ensure clear_cache_on_logout is true,
|
||||
// see https://conversejs.org/docs/html/configuration.html#allow-user-trust-override).
|
||||
@ -208,7 +209,6 @@ window.initConverse = async function initConverse ({
|
||||
isAuthenticated = true
|
||||
// FIXME: use params.oauth_providers?
|
||||
}
|
||||
}
|
||||
|
||||
if (!isAuthenticated) {
|
||||
console.log('User is not authenticated.')
|
||||
@ -221,22 +221,6 @@ window.initConverse = async function initConverse ({
|
||||
// params.muc_show_logs_before_join = true => displays muc history on top of nickname form. But it's not updated.
|
||||
}
|
||||
|
||||
if (advancedControls) {
|
||||
// with the builtin prosody, no need to use this warning (except if we open to external clients?)
|
||||
params.show_retraction_warning = false
|
||||
} else {
|
||||
// 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
|
||||
}
|
||||
|
||||
try {
|
||||
window.converse.plugins.add('livechatWindowTitlePlugin', {
|
||||
dependencies: ['converse-muc-views'],
|
||||
|
@ -21,7 +21,6 @@
|
||||
boshServiceUrl: '{{BOSH_SERVICE_URL}}',
|
||||
websocketServiceUrl: '{{WS_SERVICE_URL}}',
|
||||
authenticationUrl: '{{AUTHENTICATION_URL}}',
|
||||
advancedControls: '{{ADVANCEDCONTROLS}}' === 'true',
|
||||
autoViewerMode: '{{AUTOVIEWERMODE}}' === 'true',
|
||||
theme: '{{CONVERSEJS_THEME}}',
|
||||
forceReadonly: '{{FORCEREADONLY}}' === 'noscroll' ? '{{FORCEREADONLY}}' : '{{FORCEREADONLY}}' === 'true',
|
||||
|
@ -55,8 +55,6 @@ async function initWebchatRouter (options: RegisterServerOptionsV5): Promise<Rou
|
||||
wsUri = wsUri !== undefined ? wsUri + 'xmpp-websocket' : ''
|
||||
|
||||
let room: string
|
||||
let authenticationUrl: string = ''
|
||||
let advancedControls: boolean = false // auto join the chat in viewer mode, if not logged in
|
||||
let autoViewerMode: boolean = false
|
||||
let forceReadonly: 'true' | 'false' | 'noscroll' = 'false'
|
||||
let converseJSTheme: string = settings['converse-theme'] as string
|
||||
@ -86,10 +84,9 @@ async function initWebchatRouter (options: RegisterServerOptionsV5): Promise<Rou
|
||||
}
|
||||
}
|
||||
|
||||
authenticationUrl = options.peertubeHelpers.config.getWebserverUrl() +
|
||||
const authenticationUrl = options.peertubeHelpers.config.getWebserverUrl() +
|
||||
getBaseRouterRoute(options) +
|
||||
'api/auth'
|
||||
advancedControls = true
|
||||
if (req.query._readonly === 'true') {
|
||||
forceReadonly = 'true'
|
||||
} else if (req.query._readonly === 'noscroll') {
|
||||
@ -202,7 +199,6 @@ async function initWebchatRouter (options: RegisterServerOptionsV5): Promise<Rou
|
||||
page = page.replace(/{{BOSH_SERVICE_URL}}/g, boshUri)
|
||||
page = page.replace(/{{WS_SERVICE_URL}}/g, wsUri)
|
||||
page = page.replace(/{{AUTHENTICATION_URL}}/g, authenticationUrl)
|
||||
page = page.replace(/{{ADVANCEDCONTROLS}}/g, advancedControls ? 'true' : 'false')
|
||||
page = page.replace(/{{AUTOVIEWERMODE}}/g, autoViewerMode ? 'true' : 'false')
|
||||
page = page.replace(/{{CONVERSEJS_THEME}}/g, converseJSTheme)
|
||||
page = page.replace(/{{CONVERSEJS_AUTOCOLORS}}/g, autocolorsStyles)
|
||||
|
Loading…
x
Reference in New Issue
Block a user