diff --git a/client/admin-plugin-client-plugin.ts b/client/admin-plugin-client-plugin.ts index fb5c9e0f..c98d080c 100644 --- a/client/admin-plugin-client-plugin.ts +++ b/client/admin-plugin-client-plugin.ts @@ -221,6 +221,12 @@ function register ({ registerHook, registerSettingsScript, peertubeHelpers }: Re case 'chat-ws-uri': case 'chat-type-help-builtin-converse': return options.formValues['chat-type'] !== ('builtin-converse' as ChatType) + case 'converse-advanced': + case 'converse-theme': + return !( + options.formValues['chat-type'] === ('builtin-converse' as ChatType) || + options.formValues['chat-type'] === ('builtin-prosody' as ChatType) + ) case 'chat-uri': case 'chat-type-help-external-uri': return options.formValues['chat-type'] !== ('external-uri' as ChatType) diff --git a/conversejs/builtin.ts b/conversejs/builtin.ts index 55338090..eb9d147d 100644 --- a/conversejs/builtin.ts +++ b/conversejs/builtin.ts @@ -79,6 +79,7 @@ interface InitConverseParams { websocketServiceUrl: string authenticationUrl: string advancedControls: 'true' | 'false' + theme: string } window.initConverse = async function initConverse ({ jid, @@ -87,7 +88,8 @@ window.initConverse = async function initConverse ({ boshServiceUrl, websocketServiceUrl, authenticationUrl, - advancedControls + advancedControls, + theme }: InitConverseParams) { const isInIframe = inIframe() @@ -135,7 +137,7 @@ window.initConverse = async function initConverse ({ emoji: true, toggle_occupants: true }, - theme: 'peertube', + theme: theme || 'peertube', persistent_store: 'sessionStorage' } diff --git a/conversejs/index.html b/conversejs/index.html index 6850d3e8..f1d7d16a 100644 --- a/conversejs/index.html +++ b/conversejs/index.html @@ -20,7 +20,8 @@ boshServiceUrl: '{{BOSH_SERVICE_URL}}', websocketServiceUrl: '{{WS_SERVICE_URL}}', authenticationUrl: '{{AUTHENTICATION_URL}}', - advancedControls: '{{ADVANCEDCONTROLS}}' + advancedControls: '{{ADVANCEDCONTROLS}}', + theme: '{{CONVERSEJS_THEME}}' }) diff --git a/documentation/common.md b/documentation/common.md index 78fd23d0..d887ac45 100644 --- a/documentation/common.md +++ b/documentation/common.md @@ -45,3 +45,16 @@ You can add some custom styles that will be added to the iframe. For example a custom width: ```width:400px;``` + +### ConverseJS advanced settings + +These settings are available if you are in mode «Prosody server controlled by Peertube» +or «Connect to an existing XMPP server with ConverseJS». + +#### ConverseJS theme + +You can choose which theme to use for ConverseJS: + +- Peertube theme: this is a special theme, made especially for peertube's integration. +- Default ConverseJS theme: this is the default ConverseJS theme. +- ConverseJS concord theme: this is a theme provided by ConverseJS. diff --git a/server/lib/routers/webchat.ts b/server/lib/routers/webchat.ts index a022f6fc..24182368 100644 --- a/server/lib/routers/webchat.ts +++ b/server/lib/routers/webchat.ts @@ -1,6 +1,8 @@ import type { Router, RequestHandler, Request, Response, NextFunction } from 'express' import type { ProxyOptions } from 'express-http-proxy' -import type { ChatType, ProsodyListRoomsResult, ProsodyListRoomsResultRoom } from '../../../shared/lib/types' +import type { + ChatType, ProsodyListRoomsResult, ProsodyListRoomsResultRoom +} from '../../../shared/lib/types' import { getBaseRouterRoute, getBaseStaticRoute, isUserAdmin } from '../helpers' import { asyncMiddleware } from '../middlewares/async' import { getProsodyDomain } from '../prosody/config/domain' @@ -39,7 +41,8 @@ async function initWebchatRouter (options: RegisterServerOptions): PromiseConverseJS advanced settings' + }) + + registerSetting({ + name: 'converse-theme', + label: 'ConverseJS theme', + type: 'select', + default: 'peertube' as ConverseJSTheme, + private: true, + options: [ + { value: 'peertube', label: 'Peertube theme' }, + { value: 'default', label: 'Default ConverseJS theme' }, + { value: 'concord', label: 'ConverseJS concord theme' } + ] as Array<{value: ConverseJSTheme, label: string}>, + descriptionHTML: 'Please choose the converseJS theme you want to use.' + }) + // ********** Built-in Prosody advanced settings registerSetting({ name: 'prosody-advanced', diff --git a/shared/lib/types.ts b/shared/lib/types.ts index cd03d228..a1c08b4e 100644 --- a/shared/lib/types.ts +++ b/shared/lib/types.ts @@ -1,4 +1,5 @@ type ChatType = 'disabled' | 'builtin-prosody' | 'builtin-converse' | 'external-uri' +type ConverseJSTheme = 'peertube' | 'default' | 'concord' interface ProsodyListRoomsResultError { ok: false @@ -28,6 +29,7 @@ type ProsodyListRoomsResult = ProsodyListRoomsResultError | ProsodyListRoomsResu export { ChatType, + ConverseJSTheme, ProsodyListRoomsResult, ProsodyListRoomsResultRoom }