2022-01-11 00:29:33 +00:00
|
|
|
import type { RegisterServerOptions } from '@peertube/peertube-types'
|
2022-10-10 16:08:20 +00:00
|
|
|
import { ensureProsodyRunning } from './prosody/ctl'
|
|
|
|
import type { ConverseJSTheme } from '../../shared/lib/types'
|
2021-06-02 17:16:27 +00:00
|
|
|
|
|
|
|
function initSettings (options: RegisterServerOptions): void {
|
2021-04-13 15:13:41 +00:00
|
|
|
const { peertubeHelpers, registerSetting, settingsManager } = options
|
2021-04-08 00:43:13 +00:00
|
|
|
|
2021-06-03 10:20:19 +00:00
|
|
|
// ********** IMPORTANT NOTES
|
2021-04-12 14:31:48 +00:00
|
|
|
registerSetting({
|
2021-06-03 10:20:19 +00:00
|
|
|
type: 'html',
|
|
|
|
private: true,
|
|
|
|
descriptionHTML: '<h3>Important notes</h3>'
|
|
|
|
})
|
|
|
|
registerSetting({
|
|
|
|
type: 'html',
|
|
|
|
private: true,
|
2022-11-15 16:19:49 +00:00
|
|
|
descriptionHTML: `You can find the plugin documentation here:
|
2021-04-16 15:55:48 +00:00
|
|
|
<a href="https://github.com/JohnXLivingston/peertube-plugin-livechat/blob/main/README.md" target="_blank">
|
2022-11-15 16:19:49 +00:00
|
|
|
Peertube Plugin Livechat documentation
|
|
|
|
</a>.`
|
2021-06-03 10:20:19 +00:00
|
|
|
})
|
|
|
|
registerSetting({
|
|
|
|
type: 'html',
|
|
|
|
private: true,
|
|
|
|
descriptionHTML: `Before asking for help, please use the diagnostic tool:
|
2021-11-02 16:13:38 +00:00
|
|
|
<a class="peertube-plugin-livechat-launch-diagnostic">Launch diagnostic</a>
|
|
|
|
(if this button is not opening a new window, please try to refresh the page).`
|
2021-04-12 14:31:48 +00:00
|
|
|
})
|
2021-06-03 10:20:19 +00:00
|
|
|
|
2022-12-12 18:17:43 +00:00
|
|
|
if (process.arch !== 'x64' && process.arch !== 'x86_64') {
|
|
|
|
registerSetting({
|
|
|
|
name: 'prosody-arch-warning',
|
|
|
|
type: 'html',
|
|
|
|
private: true,
|
|
|
|
descriptionHTML: `<span class="peertube-plugin-livechat-warning">
|
|
|
|
It seems that your are using a ${process.arch} CPU,
|
|
|
|
which is not compatible with the plugin.
|
2023-02-13 17:03:23 +00:00
|
|
|
Please read
|
2022-12-12 18:17:43 +00:00
|
|
|
<a
|
2023-02-13 17:03:23 +00:00
|
|
|
href="https://johnxlivingston.github.io/peertube-plugin-livechat/fr/documentation/installation/cpu_compatibility/"
|
2022-12-12 18:17:43 +00:00
|
|
|
target="_blank"
|
|
|
|
>
|
2023-02-13 17:03:23 +00:00
|
|
|
this page
|
2022-12-12 18:17:43 +00:00
|
|
|
</a> for a workaround.
|
|
|
|
</span>`
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2022-11-15 16:19:49 +00:00
|
|
|
// ********** Chat
|
2021-06-03 10:20:19 +00:00
|
|
|
registerSetting({
|
|
|
|
type: 'html',
|
|
|
|
private: true,
|
2022-11-15 16:19:49 +00:00
|
|
|
descriptionHTML: '<h3>Chat</h3>'
|
2021-06-03 10:20:19 +00:00
|
|
|
})
|
2021-06-11 23:16:57 +00:00
|
|
|
registerSetting({
|
|
|
|
name: 'prosody-list-rooms',
|
|
|
|
label: 'List existing rooms',
|
|
|
|
type: 'html',
|
2021-11-18 09:44:30 +00:00
|
|
|
descriptionHTML: '<a class="peertube-plugin-livechat-prosody-list-rooms-btn">List rooms</a>',
|
2021-06-11 23:16:57 +00:00
|
|
|
private: true
|
|
|
|
})
|
2021-08-05 13:41:49 +00:00
|
|
|
|
2022-11-15 16:19:49 +00:00
|
|
|
// ********** Chat behaviour
|
|
|
|
registerSetting({
|
|
|
|
type: 'html',
|
|
|
|
private: true,
|
|
|
|
descriptionHTML: '<h3>Chat behaviour</h3>'
|
|
|
|
})
|
2021-08-05 13:41:49 +00:00
|
|
|
registerSetting({
|
|
|
|
name: 'prosody-room-type',
|
|
|
|
label: 'Room type',
|
|
|
|
type: 'select',
|
|
|
|
descriptionHTML: 'You can choose here to have separate rooms for each video, or to group them by channel.',
|
|
|
|
private: false,
|
|
|
|
default: 'video',
|
|
|
|
options: [
|
|
|
|
{ value: 'video', label: 'Each video has its own webchat room' },
|
|
|
|
{ value: 'channel', label: 'Webchat rooms are grouped by channel' }
|
|
|
|
]
|
|
|
|
})
|
2021-06-03 10:24:09 +00:00
|
|
|
registerSetting({
|
|
|
|
name: 'chat-auto-display',
|
|
|
|
label: 'Automatically open the chat',
|
|
|
|
descriptionHTML: 'When watching a video, the chatbox will automatically open',
|
|
|
|
type: 'input-checkbox',
|
|
|
|
default: true,
|
|
|
|
private: false
|
|
|
|
})
|
|
|
|
registerSetting({
|
|
|
|
name: 'chat-open-blank',
|
|
|
|
label: 'Show the «open in new window» button',
|
2021-06-11 12:45:18 +00:00
|
|
|
descriptionHTML: 'There will be a button for opening the web chat in a new window.',
|
2021-06-03 10:24:09 +00:00
|
|
|
private: false,
|
|
|
|
type: 'input-checkbox',
|
|
|
|
default: true
|
|
|
|
})
|
2022-11-15 16:19:49 +00:00
|
|
|
registerSetting({
|
|
|
|
name: 'chat-share-url',
|
|
|
|
label: 'Show the «share chat link» button',
|
|
|
|
descriptionHTML: 'There will be a button for sharing a chat url (could be used to intregrated in OBS for example).',
|
|
|
|
private: false,
|
|
|
|
type: 'select',
|
|
|
|
default: 'owner',
|
|
|
|
options: [
|
|
|
|
{ label: 'Show for nobody', value: 'nobody' },
|
|
|
|
{ label: 'Show for everyone', value: 'everyone' },
|
|
|
|
{ label: 'Show for the video owner', value: 'owner' },
|
|
|
|
{ label: 'Show for the video owner and instance\'s moderators', value: 'owner+moderators' }
|
|
|
|
]
|
|
|
|
})
|
2021-06-08 16:08:58 +00:00
|
|
|
registerSetting({
|
|
|
|
name: 'chat-per-live-video',
|
|
|
|
label: 'Users can activate the chat for their lives',
|
|
|
|
type: 'input-checkbox',
|
|
|
|
default: true,
|
2021-06-11 12:45:18 +00:00
|
|
|
descriptionHTML: 'If checked, all live videos will have a checkbox in their properties for enabling the web chat.',
|
2021-06-08 16:08:58 +00:00
|
|
|
private: false
|
|
|
|
})
|
|
|
|
registerSetting({
|
|
|
|
name: 'chat-per-live-video-warning',
|
|
|
|
type: 'html',
|
|
|
|
private: true,
|
2021-06-11 12:45:18 +00:00
|
|
|
descriptionHTML:
|
|
|
|
`<span class="peertube-plugin-livechat-warning">
|
2021-06-08 16:08:58 +00:00
|
|
|
You have enabled the setting «Users can activate the chat for their lives».
|
|
|
|
It is redundant with the «Activate chat for all lives» setting.
|
2021-06-03 10:24:09 +00:00
|
|
|
</span>`
|
|
|
|
})
|
|
|
|
registerSetting({
|
|
|
|
name: 'chat-all-lives',
|
|
|
|
label: 'Activate chat for all lives',
|
|
|
|
type: 'input-checkbox',
|
2021-06-08 16:08:58 +00:00
|
|
|
default: false,
|
2021-06-03 10:24:09 +00:00
|
|
|
descriptionHTML: 'If checked, the chat will be enabled for all lives.',
|
|
|
|
private: false
|
|
|
|
})
|
|
|
|
registerSetting({
|
|
|
|
name: 'chat-all-non-lives',
|
|
|
|
label: 'Activate chat for all non-lives',
|
|
|
|
type: 'input-checkbox',
|
|
|
|
default: false,
|
|
|
|
descriptionHTML: 'If checked, the chat will be enable for all video that are not lives.',
|
|
|
|
private: false
|
|
|
|
})
|
|
|
|
registerSetting({
|
|
|
|
name: 'chat-videos-list',
|
2021-06-11 12:45:18 +00:00
|
|
|
label: 'Activate chat for these videos',
|
2021-06-03 10:24:09 +00:00
|
|
|
type: 'input-textarea',
|
|
|
|
default: '',
|
2021-06-11 12:45:18 +00:00
|
|
|
descriptionHTML:
|
|
|
|
`Videos UUIDs for which we want a web chat.
|
|
|
|
Can be non-live videos. One per line. <br />
|
|
|
|
You can add comments: everything after the # character will be stripped off, and empty lines ignored.<br />
|
|
|
|
Don't add private videos, the UUIDs will be send to frontend.`,
|
2021-06-03 10:24:09 +00:00
|
|
|
private: false
|
|
|
|
})
|
2022-04-11 16:12:12 +00:00
|
|
|
registerSetting({
|
|
|
|
name: 'chat-no-anonymous',
|
|
|
|
label: 'Hide the chat for anonymous users',
|
|
|
|
type: 'input-checkbox',
|
|
|
|
default: false,
|
|
|
|
descriptionHTML: 'If checked, anonymous Peertube users won\'t see the chat.',
|
|
|
|
private: false
|
|
|
|
})
|
2021-06-03 10:24:09 +00:00
|
|
|
|
2022-11-15 16:19:49 +00:00
|
|
|
// ********** Theming
|
2021-04-08 00:43:13 +00:00
|
|
|
registerSetting({
|
2022-11-15 16:19:49 +00:00
|
|
|
name: 'theming-advanced',
|
2021-11-18 10:08:12 +00:00
|
|
|
type: 'html',
|
|
|
|
private: true,
|
2022-11-15 16:19:49 +00:00
|
|
|
descriptionHTML: '<h3>Theming</h3>'
|
2021-11-18 10:08:12 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
registerSetting({
|
|
|
|
name: 'converse-theme',
|
|
|
|
label: 'ConverseJS theme',
|
|
|
|
type: 'select',
|
|
|
|
default: 'peertube' as ConverseJSTheme,
|
2021-11-19 15:45:10 +00:00
|
|
|
private: false,
|
2021-11-18 10:08:12 +00:00
|
|
|
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.'
|
|
|
|
})
|
|
|
|
|
2021-11-19 15:45:10 +00:00
|
|
|
registerSetting({
|
|
|
|
name: 'converse-autocolors',
|
|
|
|
label: 'Automatic color detection',
|
|
|
|
type: 'input-checkbox',
|
|
|
|
default: true,
|
|
|
|
private: false,
|
|
|
|
descriptionHTML:
|
|
|
|
`Try to auto detect colors from user's current theme.<br>
|
|
|
|
When this settings is enabled, the plugin tries to auto-detect colors to apply to the chat theme.<br>
|
|
|
|
If this is not correctly working for some of your Peertube theme, you can disable this option.
|
|
|
|
You can report the bug on the official
|
|
|
|
<a href="https://github.com/JohnXLivingston/peertube-plugin-livechat/issues" target="_blank">
|
|
|
|
issue tracker
|
|
|
|
</a>. Don't forget to specify which theme is not working.`
|
|
|
|
})
|
|
|
|
|
2022-11-15 16:19:49 +00:00
|
|
|
registerSetting({
|
|
|
|
name: 'chat-style',
|
|
|
|
label: 'Webchat iframe style attribute',
|
|
|
|
type: 'input-textarea',
|
|
|
|
default: '',
|
|
|
|
descriptionHTML:
|
|
|
|
`Additional styles to be added on the iframe style attribute. <br>
|
|
|
|
Example: height:400px;`,
|
|
|
|
private: false
|
|
|
|
})
|
|
|
|
|
|
|
|
// ********** Chat server advanced settings
|
2021-07-13 15:40:29 +00:00
|
|
|
registerSetting({
|
|
|
|
name: 'prosody-advanced',
|
|
|
|
type: 'html',
|
|
|
|
private: true,
|
2022-11-15 16:19:49 +00:00
|
|
|
descriptionHTML: '<h3>Chat server advanced settings</h3>'
|
2021-07-13 15:40:29 +00:00
|
|
|
})
|
|
|
|
|
2021-12-21 18:54:37 +00:00
|
|
|
registerSetting({
|
2022-11-15 16:19:49 +00:00
|
|
|
name: 'chat-help-builtin-prosody',
|
|
|
|
type: 'html',
|
|
|
|
label: 'Prosody server',
|
|
|
|
descriptionHTML: `This plugin uses the Prosody XMPP server to handle chat rooms.<br>
|
|
|
|
This plugin comes with a Prosody AppImage, that will be used to run the service.`,
|
|
|
|
private: true
|
|
|
|
})
|
|
|
|
|
|
|
|
registerSetting({
|
|
|
|
name: 'use-system-prosody',
|
|
|
|
type: 'input-checkbox',
|
|
|
|
label: 'Use system Prosody',
|
|
|
|
descriptionHTML: `Warning: don't check this settings if you are not sure of what you are doing.<br>
|
|
|
|
By checking this settings, your Peertube will use the Prosody server that comes with your system,
|
|
|
|
and not the embeded AppImage.<br>
|
|
|
|
Only use this if you encounter problems with the embedded Prosody.`,
|
|
|
|
private: true,
|
|
|
|
default: false
|
2021-12-21 18:54:37 +00:00
|
|
|
})
|
2022-11-15 16:19:49 +00:00
|
|
|
|
2022-12-08 10:25:57 +00:00
|
|
|
registerSetting({
|
|
|
|
name: 'disable-websocket',
|
|
|
|
type: 'input-checkbox',
|
|
|
|
label: 'Disable Websocket',
|
|
|
|
descriptionHTML: `With Peertube >= 5.0.0, this plugin try to use Websocket connection for chatting.
|
|
|
|
If the user's browser or connection is not compatible, the browser will automatically fallback on the BOSH protocol.
|
|
|
|
<br>
|
|
|
|
But in rare case, this can fail. For example if you have a reverse proxy in front of Peertube that does not
|
|
|
|
allow Websocket connection for plugins.
|
|
|
|
In this case, you can check this settings to disable Websocket connections.`,
|
|
|
|
private: true,
|
|
|
|
default: false
|
|
|
|
})
|
|
|
|
|
2022-11-15 16:19:49 +00:00
|
|
|
registerSetting({
|
|
|
|
name: 'prosody-port',
|
|
|
|
label: 'Prosody port',
|
|
|
|
type: 'input',
|
|
|
|
default: '52800',
|
|
|
|
private: true,
|
|
|
|
descriptionHTML:
|
|
|
|
`The port that will be used by the builtin Prosody server.<br>
|
|
|
|
Change it if this port is already in use on your server.<br>
|
|
|
|
You can close this port on your firewall, it will not be accessed from the outer world.`
|
|
|
|
})
|
|
|
|
|
2021-07-14 17:22:25 +00:00
|
|
|
registerSetting({
|
|
|
|
name: 'prosody-peertube-uri',
|
|
|
|
label: 'Peertube url for API calls',
|
|
|
|
type: 'input',
|
|
|
|
default: '',
|
|
|
|
private: true,
|
|
|
|
descriptionHTML:
|
|
|
|
`Please let this settings empty if you don't know what you are doing.<br>
|
|
|
|
In some rare case, Prosody can't call Peertube's API from its public URI.
|
2022-11-15 17:04:51 +00:00
|
|
|
You can use this field to customise Peertube's URI for Prosody modules
|
|
|
|
(for example with «http://localhost:9000» or «http://127.0.0.1:9000»).`
|
2021-07-14 17:22:25 +00:00
|
|
|
})
|
|
|
|
|
2021-12-01 11:57:15 +00:00
|
|
|
registerSetting({
|
|
|
|
name: 'prosody-muc-log-by-default',
|
|
|
|
label: 'Log rooms content by default',
|
|
|
|
type: 'input-checkbox',
|
|
|
|
default: true,
|
|
|
|
private: true,
|
|
|
|
descriptionHTML:
|
|
|
|
`If checked, room contents will be saved by default.
|
2022-11-15 16:19:49 +00:00
|
|
|
Any user that join a room will see what was written before he joins.<br>
|
2021-12-01 11:57:15 +00:00
|
|
|
Please note that it is always possible to enable/disable the content
|
|
|
|
archiving for a specific room, by editing its properties.
|
|
|
|
`
|
|
|
|
})
|
|
|
|
|
|
|
|
registerSetting({
|
|
|
|
name: 'prosody-muc-expiration',
|
|
|
|
label: 'Room logs expiration',
|
|
|
|
type: 'input',
|
|
|
|
default: '1w',
|
|
|
|
private: true,
|
|
|
|
descriptionHTML:
|
|
|
|
`You can choose here how long the chatting room's content is kept by the server. The value can be:
|
|
|
|
<ul>
|
|
|
|
<li><b>60</b>: the content will be saved for 60 <b>seconds</b>. You can replace 60 by any integer value.</li>
|
|
|
|
<li><b>1d</b>: the content will be saved for 1 <b>day</b>. You can replace 1 by any integer value.</li>
|
|
|
|
<li><b>1w</b>: the content will be saved for 1 <b>week</b>. You can replace 1 by any integer value.</li>
|
|
|
|
<li><b>1m</b>: the content will be saved for 1 <b>month</b>. You can replace 1 by any integer value.</li>
|
|
|
|
<li><b>1y</b>: the content will be saved for 1 <b>year</b>. You can replace 1 by any integer value.</li>
|
|
|
|
<li><b>never</b>: the content will never expire, and will be kept forever.</li>
|
|
|
|
</ul>`
|
|
|
|
})
|
|
|
|
|
2021-07-13 15:40:29 +00:00
|
|
|
registerSetting({
|
|
|
|
name: 'prosody-c2s',
|
|
|
|
label: 'Enable client to server connections',
|
|
|
|
type: 'input-checkbox',
|
|
|
|
default: false,
|
|
|
|
private: true,
|
|
|
|
descriptionHTML:
|
|
|
|
`Enable XMPP clients to connect to the builtin Prosody server.<br>
|
|
|
|
This option alone only allows connections from localhost clients.`
|
|
|
|
})
|
|
|
|
|
|
|
|
registerSetting({
|
|
|
|
name: 'prosody-c2s-port',
|
|
|
|
label: 'Prosody client to server port',
|
|
|
|
type: 'input',
|
|
|
|
default: '52822',
|
|
|
|
private: true,
|
|
|
|
descriptionHTML:
|
|
|
|
`The port that will be used by the c2s module of the builtin Prosody server.<br>
|
|
|
|
XMPP clients shall use this port to connect.<br>
|
|
|
|
Change it if this port is already in use on your server.<br>
|
2021-12-11 18:09:01 +00:00
|
|
|
You can keep this port closed on your firewall for now, it will not be accessed from the outer world.`
|
|
|
|
})
|
|
|
|
|
|
|
|
registerSetting({
|
|
|
|
name: 'prosody-components',
|
|
|
|
label: 'Enable custom Prosody external components',
|
|
|
|
type: 'input-checkbox',
|
|
|
|
default: false,
|
|
|
|
private: true,
|
|
|
|
descriptionHTML:
|
|
|
|
`Enable the use of external XMPP components.<br>
|
|
|
|
This option alone only allows connections from localhost.<br>
|
|
|
|
This feature can for example be used to connect some bots to the chatting rooms.`
|
|
|
|
})
|
|
|
|
|
|
|
|
registerSetting({
|
|
|
|
name: 'prosody-components-port',
|
|
|
|
label: 'Prosody external components port',
|
|
|
|
type: 'input',
|
|
|
|
default: '53470',
|
|
|
|
private: true,
|
|
|
|
descriptionHTML:
|
|
|
|
`The port that will be used by XMPP components to connect to the Prosody server.<br>
|
|
|
|
Change it if this port is already in use on your server.<br>
|
|
|
|
You can keep this port closed on your firewall for now, it will not be accessed from the outer world.`
|
|
|
|
})
|
|
|
|
|
|
|
|
registerSetting({
|
|
|
|
name: 'prosody-components-list',
|
|
|
|
label: 'External components',
|
|
|
|
type: 'input-textarea',
|
|
|
|
default: '',
|
|
|
|
private: true,
|
|
|
|
descriptionHTML:
|
|
|
|
`The external components to create:
|
|
|
|
<ul>
|
|
|
|
<li>One per line.</li>
|
|
|
|
<li>Use the format «component_name:component_secret» (spaces will be trimmed)</li>
|
|
|
|
<li>You can add comments: everything after the # character will be stripped off, and empty lines ignored</li>
|
|
|
|
<li>The name can only contain alphanumeric characters and dots</li>
|
|
|
|
<li>
|
|
|
|
If the name contains only alphanumeric characters, it will be suffixed with the XMPP domain.
|
|
|
|
For exemple «bridge» will become «bridge.your_domain.tld».
|
|
|
|
You can also specify a full domain name, but you have to make sure to configure your DNS correctly.
|
|
|
|
</li>
|
|
|
|
<li>Only use alphanumeric characters in the secret passphrase (use at least 15 characters).</li>
|
|
|
|
</ul>`
|
2021-07-13 15:40:29 +00:00
|
|
|
})
|
|
|
|
|
2021-06-03 10:24:09 +00:00
|
|
|
// ********** settings changes management
|
2022-10-10 16:08:20 +00:00
|
|
|
settingsManager.onSettingsChange(async (_settings: any) => {
|
|
|
|
peertubeHelpers.logger.info('Saving settings, ensuring prosody is running')
|
|
|
|
await ensureProsodyRunning(options)
|
2021-04-13 15:13:41 +00:00
|
|
|
})
|
2021-04-08 00:43:13 +00:00
|
|
|
}
|
2021-06-02 17:16:27 +00:00
|
|
|
|
|
|
|
export {
|
|
|
|
initSettings
|
|
|
|
}
|