diff --git a/CHANGELOG.md b/CHANGELOG.md index 496cb11f..8f2d8998 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ ### Features +* Builtin Prosody: Readonly mode. You can open the chat in readonly mode. Could be used to integrate in OBS for example. * Builtin Prosody: you can now allow «external XMPP components» to connect. This can be used for exemple to connect bots or bridges. For now, only connections from localhost will be allowed. ### Minor changes and fixes @@ -11,6 +12,7 @@ * Spanish translations (thanks [rnek0](https://github.com/rnek0)). * Hide secret keys in diagnostic tool. * Builtin ConverseJS mode: fix advanced controls hiding. +* Builtin Prosody & Builtin ConverseJS: muc_mention_autocomplete_min_chars set to 2 (3 previously) ## v5.0.2 diff --git a/conversejs/builtin.ts b/conversejs/builtin.ts index ccc5ad03..2af79be3 100644 --- a/conversejs/builtin.ts +++ b/conversejs/builtin.ts @@ -82,6 +82,7 @@ interface InitConverseParams { websocketServiceUrl: string authenticationUrl: string advancedControls: boolean + forceReadonly: boolean theme: string } window.initConverse = async function initConverse ({ @@ -92,18 +93,22 @@ window.initConverse = async function initConverse ({ websocketServiceUrl, authenticationUrl, advancedControls, + forceReadonly, theme }: InitConverseParams) { const isInIframe = inIframe() + const body = document.querySelector('body') if (isInIframe) { - const body = document.querySelector('body') if (body) { body.classList.add('livechat-iframe') // prevent horizontal scrollbar when in iframe. (don't know why, but does not work if done by CSS) body.style.overflowX = 'hidden' } } + if (forceReadonly) { + body?.classList.add('livechat-readonly') + } const params: any = { assets_path: assetsPath, @@ -125,7 +130,7 @@ window.initConverse = async function initConverse ({ auto_focus: !isInIframe, hide_muc_participants: isInIframe, play_sounds: false, - muc_mention_autocomplete_min_chars: 3, + muc_mention_autocomplete_min_chars: 2, muc_mention_autocomplete_filter: 'contains', muc_instant_rooms: true, show_client_info: false, @@ -172,6 +177,9 @@ window.initConverse = async function initConverse ({ if (!isAuthenticated) { console.log('User is not authenticated.') + if (forceReadonly) { + params.nickname = 'Viewer ' + (new Date()).getTime().toString() + } // TODO: try to make these params work // params.muc_nickname_from_jid = true => compute the muc nickname from the jid (will be random here) // params.auto_register_muc_nickname = true => maybe not relevant here (dont do what i thought) diff --git a/conversejs/custom/sass/livechat.scss b/conversejs/custom/sass/livechat.scss index 520e392c..53e2c8a9 100644 --- a/conversejs/custom/sass/livechat.scss +++ b/conversejs/custom/sass/livechat.scss @@ -15,3 +15,13 @@ body.livechat-iframe #conversejs .chat-head { } } } + +// Readonly mode +body.livechat-readonly #conversejs { + .chat-head, + .bottom-panel, + converse-message-actions, + converse-muc-sidebar { + display: none !important; + } +} diff --git a/conversejs/index.html b/conversejs/index.html index 3c8c6b97..51259fc8 100644 --- a/conversejs/index.html +++ b/conversejs/index.html @@ -22,7 +22,8 @@ websocketServiceUrl: '{{WS_SERVICE_URL}}', authenticationUrl: '{{AUTHENTICATION_URL}}', advancedControls: '{{ADVANCEDCONTROLS}}' === 'true', - theme: '{{CONVERSEJS_THEME}}' + theme: '{{CONVERSEJS_THEME}}', + forceReadonly: '{{FORCEREADONLY}}' === 'true' }) diff --git a/server/lib/routers/webchat.ts b/server/lib/routers/webchat.ts index 7342349c..27550d64 100644 --- a/server/lib/routers/webchat.ts +++ b/server/lib/routers/webchat.ts @@ -53,6 +53,7 @@ async function initWebchatRouter (options: RegisterServerOptions): Promise