Chat federation: new settings to disable the feature.
This commit is contained in:
parent
4c138f3f5b
commit
01e7fdc9b6
@ -16,6 +16,14 @@ list_rooms_label: "Bestehende Räume auflisten"
|
|||||||
list_rooms_description: |
|
list_rooms_description: |
|
||||||
<a class="peertube-plugin-livechat-prosody-list-rooms-btn">Räume auflisten</a>
|
<a class="peertube-plugin-livechat-prosody-list-rooms-btn">Räume auflisten</a>
|
||||||
|
|
||||||
|
federation_description: ~
|
||||||
|
|
||||||
|
federation_no_remote_chat_label: ~
|
||||||
|
federation_no_remote_chat_description: ~
|
||||||
|
|
||||||
|
federation_dont_publish_remotely_label: ~
|
||||||
|
federation_dont_publish_remotely_description: ~
|
||||||
|
|
||||||
chat_behaviour_description: "<h3>Chatverhalten</h3>"
|
chat_behaviour_description: "<h3>Chatverhalten</h3>"
|
||||||
|
|
||||||
room_type_label: "Raumtyp"
|
room_type_label: "Raumtyp"
|
||||||
|
@ -16,6 +16,27 @@ list_rooms_label: "List existing rooms"
|
|||||||
list_rooms_description: |
|
list_rooms_description: |
|
||||||
<a class="peertube-plugin-livechat-prosody-list-rooms-btn">List rooms</a>
|
<a class="peertube-plugin-livechat-prosody-list-rooms-btn">List rooms</a>
|
||||||
|
|
||||||
|
federation_description: |
|
||||||
|
<h3>Federation</h3>
|
||||||
|
Following settings concern the fedration with other Peertube instances,
|
||||||
|
and other fediverse softwares.
|
||||||
|
|
||||||
|
federation_no_remote_chat_label: "Don't display remote chats"
|
||||||
|
federation_no_remote_chat_description: |
|
||||||
|
By checking this setting, your instance will never display chats from remote videos.
|
||||||
|
|
||||||
|
federation_dont_publish_remotely_label: "Don't publish chat information"
|
||||||
|
federation_dont_publish_remotely_description: |
|
||||||
|
By checking this setting, your instance will not publish chat information on the fediverse.
|
||||||
|
Remote Peertube instances will not be aware that they are chat rooms associated to your videos.<br>
|
||||||
|
<b>Please note</b>: if you already had chats in progress, it is possible that the information has already been published.
|
||||||
|
You will have to wait for the next video update before the information is unpublished.
|
||||||
|
Also, if you disable this setting, you'll have to wait for the videos to be updated before the information are
|
||||||
|
published again. This update happens among others when a live event resumes or stops.<br>
|
||||||
|
<b>Please note</b>: this setting only affects the publication of information via the ActivityPub protocol.
|
||||||
|
It will not prevent a remote application from otherwise detecting the presence of chats, and trying to connect to it.
|
||||||
|
|
||||||
|
|
||||||
chat_behaviour_description: "<h3>Chat behaviour</h3>"
|
chat_behaviour_description: "<h3>Chat behaviour</h3>"
|
||||||
|
|
||||||
room_type_label: "Room type"
|
room_type_label: "Room type"
|
||||||
|
@ -16,6 +16,26 @@ list_rooms_label: "Lister les salons de tchat existants"
|
|||||||
list_rooms_description: |
|
list_rooms_description: |
|
||||||
<a class="peertube-plugin-livechat-prosody-list-rooms-btn">Lister les salons</a>
|
<a class="peertube-plugin-livechat-prosody-list-rooms-btn">Lister les salons</a>
|
||||||
|
|
||||||
|
federation_description: |
|
||||||
|
<h3>Fédération</h3>
|
||||||
|
Les paramètres ci-dessous concerne la fédération avec d'autres instances Peertube
|
||||||
|
et autres logiciels du fédivers.
|
||||||
|
|
||||||
|
federation_no_remote_chat_label: "Ne pas afficher les tchats distants"
|
||||||
|
federation_no_remote_chat_description: |
|
||||||
|
En cochant ce paramètre, votre instance n'affichera jamais les tchats sur les vidéos distantes.
|
||||||
|
|
||||||
|
federation_dont_publish_remotely_label: "Ne pas publier les informations de tchats"
|
||||||
|
federation_dont_publish_remotely_description: |
|
||||||
|
En cochant ce paramètre, votre instance ne publiera pas les informations de tchat sur le fédivers.
|
||||||
|
Les instances Peertube distantes ne sauront pas qu'un tchat est associé aux vidéos.<br>
|
||||||
|
<b>Attention</b>: si vous aviez déjà des tchats en cours, il est possible que les informations aient déjà été publiées.
|
||||||
|
Il faudra attendre la prochaine mise à jour des vidéos pour que les informations soient dépubliées.
|
||||||
|
De même, si vous désactivé ce paramètre, il faudra attendre que les vidéos soient mises à jour pour à nouveau
|
||||||
|
publier les informations. Cette mise à jour intervient entre autre quand un live reprend ou s'arrête.<br>
|
||||||
|
<b>Attention</b>: ce paramètre ne joue que sur la publication d'informations via le protocole ActivityPub. Il n'empêchera
|
||||||
|
pas une application distante de détecter autrement la présence de tchat, et de tenter de s'y connecter.
|
||||||
|
|
||||||
chat_behaviour_description: "<h3>Comportement du tchat</h3>"
|
chat_behaviour_description: "<h3>Comportement du tchat</h3>"
|
||||||
|
|
||||||
room_type_label: "Type de salon"
|
room_type_label: "Type de salon"
|
||||||
|
@ -16,6 +16,14 @@ list_rooms_label: "Elenco delle chat room esistenti"
|
|||||||
list_rooms_description: |
|
list_rooms_description: |
|
||||||
<a class="peertube-plugin-livechat-prosody-list-rooms-btn">Elenca le chat room</a>
|
<a class="peertube-plugin-livechat-prosody-list-rooms-btn">Elenca le chat room</a>
|
||||||
|
|
||||||
|
federation_description: ~
|
||||||
|
|
||||||
|
federation_no_remote_chat_label: ~
|
||||||
|
federation_no_remote_chat_description: ~
|
||||||
|
|
||||||
|
federation_dont_publish_remotely_label: ~
|
||||||
|
federation_dont_publish_remotely_description: ~
|
||||||
|
|
||||||
chat_behaviour_description: "<h3>Comportamento della chat</h3>"
|
chat_behaviour_description: "<h3>Comportamento della chat</h3>"
|
||||||
|
|
||||||
room_type_label: "Tipo di chat room"
|
room_type_label: "Tipo di chat room"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import type { RegisterServerOptions, VideoObject, MVideoAP, MVideoFullLight } from '@peertube/peertube-types'
|
import type { RegisterServerOptions, VideoObject, MVideoAP, MVideoFullLight } from '@peertube/peertube-types'
|
||||||
import { videoHasWebchat } from '../../../shared/lib/video'
|
import { videoHasWebchat } from '../../../shared/lib/video'
|
||||||
import { getBoshUri, getWSUri } from '../uri/webchat'
|
import { getBoshUri, getWSUri } from '../uri/webchat'
|
||||||
import { fullUri } from '../uri/full'
|
import { canonicalizePluginUri } from '../uri/canonicalize'
|
||||||
import { getProsodyDomain } from '../prosody/config/domain'
|
import { getProsodyDomain } from '../prosody/config/domain'
|
||||||
|
|
||||||
interface LiveChatVideoObject extends VideoObject {
|
interface LiveChatVideoObject extends VideoObject {
|
||||||
@ -37,9 +37,14 @@ export async function initFederation (options: RegisterServerOptions): Promise<v
|
|||||||
'chat-all-non-lives',
|
'chat-all-non-lives',
|
||||||
'chat-videos-list',
|
'chat-videos-list',
|
||||||
'disable-websocket',
|
'disable-websocket',
|
||||||
'prosody-room-type'
|
'prosody-room-type',
|
||||||
|
'federation-dont-publish-remotely'
|
||||||
])
|
])
|
||||||
|
|
||||||
|
if (settings['federation-dont-publish-remotely']) {
|
||||||
|
return jsonld
|
||||||
|
}
|
||||||
|
|
||||||
const hasChat = await videoHasWebchat({
|
const hasChat = await videoHasWebchat({
|
||||||
'chat-per-live-video': !!settings['chat-per-live-video'],
|
'chat-per-live-video': !!settings['chat-per-live-video'],
|
||||||
'chat-all-lives': !!settings['chat-all-lives'],
|
'chat-all-lives': !!settings['chat-all-lives'],
|
||||||
@ -62,7 +67,7 @@ export async function initFederation (options: RegisterServerOptions): Promise<v
|
|||||||
|
|
||||||
const links = [{
|
const links = [{
|
||||||
type: 'xmpp-bosh-anonymous',
|
type: 'xmpp-bosh-anonymous',
|
||||||
url: fullUri(options, getBoshUri(options)),
|
url: canonicalizePluginUri(options, getBoshUri(options), { removePluginVersion: true }),
|
||||||
jid: userJID
|
jid: userJID
|
||||||
}]
|
}]
|
||||||
if (!settings['disable-websocket']) {
|
if (!settings['disable-websocket']) {
|
||||||
@ -70,7 +75,10 @@ export async function initFederation (options: RegisterServerOptions): Promise<v
|
|||||||
if (wsUri) {
|
if (wsUri) {
|
||||||
links.push({
|
links.push({
|
||||||
type: 'xmpp-websocket-anonymous',
|
type: 'xmpp-websocket-anonymous',
|
||||||
url: fullUri(options, wsUri),
|
url: canonicalizePluginUri(options, wsUri, {
|
||||||
|
removePluginVersion: true,
|
||||||
|
protocol: 'ws'
|
||||||
|
}),
|
||||||
jid: userJID
|
jid: userJID
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -3,9 +3,12 @@ import type { Response } from 'express'
|
|||||||
import type { IncomingMessage } from 'http'
|
import type { IncomingMessage } from 'http'
|
||||||
import type { Duplex } from 'stream'
|
import type { Duplex } from 'stream'
|
||||||
|
|
||||||
|
const pluginVersionRegexp = /^\d+\.\d+\.\d+(?:-(?:rc|alpha|beta)\.\d+)?$/
|
||||||
|
const pluginVersionWordBreakRegex = /\b\d+\.\d+\.\d+(?:-(?:rc|alpha|beta)\.\d+)?\b/
|
||||||
|
|
||||||
const packagejson: any = require('../../../package.json')
|
const packagejson: any = require('../../../package.json')
|
||||||
const version: string = packagejson.version || ''
|
const version: string = packagejson.version || ''
|
||||||
if (!/^\d+\.\d+\.\d+/.test(version)) {
|
if (!pluginVersionRegexp.test(version)) {
|
||||||
throw new Error('Incorrect version in package.json.')
|
throw new Error('Incorrect version in package.json.')
|
||||||
}
|
}
|
||||||
const pluginName: string = packagejson.name || ''
|
const pluginName: string = packagejson.name || ''
|
||||||
@ -94,5 +97,7 @@ export {
|
|||||||
isUserAdmin,
|
isUserAdmin,
|
||||||
getUserNickname,
|
getUserNickname,
|
||||||
pluginName,
|
pluginName,
|
||||||
pluginShortName
|
pluginShortName,
|
||||||
|
pluginVersionRegexp,
|
||||||
|
pluginVersionWordBreakRegex
|
||||||
}
|
}
|
||||||
|
@ -97,6 +97,29 @@ Please read
|
|||||||
private: true
|
private: true
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// ********** Federation
|
||||||
|
registerSetting({
|
||||||
|
type: 'html',
|
||||||
|
private: true,
|
||||||
|
descriptionHTML: loc('federation_description')
|
||||||
|
})
|
||||||
|
registerSetting({
|
||||||
|
name: 'federation-no-remote-chat',
|
||||||
|
label: loc('federation_no_remote_chat_label'),
|
||||||
|
descriptionHTML: loc('federation_no_remote_chat_description'),
|
||||||
|
type: 'input-checkbox',
|
||||||
|
default: false,
|
||||||
|
private: false
|
||||||
|
})
|
||||||
|
registerSetting({
|
||||||
|
name: 'federation-dont-publish-remotely',
|
||||||
|
label: loc('federation_dont_publish_remotely_label'),
|
||||||
|
descriptionHTML: loc('federation_dont_publish_remotely_description'),
|
||||||
|
type: 'input-checkbox',
|
||||||
|
default: false,
|
||||||
|
private: true
|
||||||
|
})
|
||||||
|
|
||||||
// ********** Chat behaviour
|
// ********** Chat behaviour
|
||||||
registerSetting({
|
registerSetting({
|
||||||
type: 'html',
|
type: 'html',
|
||||||
|
@ -1,10 +1,52 @@
|
|||||||
import type { RegisterServerOptions } from '@peertube/peertube-types'
|
import type { RegisterServerOptions } from '@peertube/peertube-types'
|
||||||
|
import { pluginVersionWordBreakRegex } from '../helpers'
|
||||||
import * as url from 'url'
|
import * as url from 'url'
|
||||||
|
|
||||||
export function fullUri (options: RegisterServerOptions, path: string): string {
|
const removeVersionRegex = new RegExp(
|
||||||
if (path.startsWith('https://') || path.startsWith('http://')) {
|
/\/plugins\/livechat\//.source +
|
||||||
return path
|
pluginVersionWordBreakRegex.source +
|
||||||
|
/\//.source
|
||||||
|
)
|
||||||
|
|
||||||
|
interface CanonicalizeOptions {
|
||||||
|
protocol?: 'http' | 'ws'
|
||||||
|
removePluginVersion?: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Takes a Plugin uri or route path (for example an API endpoint, the websocket route, ...),
|
||||||
|
* and returns a canonicalized version that include the host, and can handle different options
|
||||||
|
* (with the given scheme, without the plugin version, ...)
|
||||||
|
* @param options Peertube server options
|
||||||
|
* @param path the uri to canonicalize
|
||||||
|
* @param canonicalizeOptions canonicalize options
|
||||||
|
* @returns the canonicalize uri
|
||||||
|
*/
|
||||||
|
export function canonicalizePluginUri (
|
||||||
|
options: RegisterServerOptions,
|
||||||
|
path: string,
|
||||||
|
canonicalizeOptions?: CanonicalizeOptions
|
||||||
|
): string {
|
||||||
|
let uri: url.URL
|
||||||
|
if (path.match(/^(http|ws)s?:\/\//)) {
|
||||||
|
uri = new url.URL(path)
|
||||||
|
} else {
|
||||||
|
uri = new url.URL(path, options.peertubeHelpers.config.getWebserverUrl())
|
||||||
|
}
|
||||||
|
if (canonicalizeOptions?.protocol) {
|
||||||
|
// Assuming that current protocol is https? or wss?, other cases dont concern us, and will be buggy
|
||||||
|
const currentProtocolSecure = uri.protocol.endsWith('s')
|
||||||
|
if (canonicalizeOptions.protocol === 'http') {
|
||||||
|
uri.protocol = currentProtocolSecure ? 'https' : 'http'
|
||||||
|
} else if (canonicalizeOptions.protocol === 'ws') {
|
||||||
|
uri.protocol = currentProtocolSecure ? 'wss' : 'ws'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (canonicalizeOptions?.removePluginVersion) {
|
||||||
|
uri.pathname = uri.pathname.replace(
|
||||||
|
removeVersionRegex,
|
||||||
|
'/plugins/livechat/'
|
||||||
|
)
|
||||||
}
|
}
|
||||||
const uri = new url.URL(path, options.peertubeHelpers.config.getWebserverUrl())
|
|
||||||
return uri.toString()
|
return uri.toString()
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,28 @@ Dieser Abschnitt beschreibt die Einstellungsseite des Plugins.
|
|||||||
Wenn der «Bestehende Räume auflisten» («List rooms») Knopf gedrückt wird, werden alle bestehenden Chaträume aufgelistet.
|
Wenn der «Bestehende Räume auflisten» («List rooms») Knopf gedrückt wird, werden alle bestehenden Chaträume aufgelistet.
|
||||||
Sie können die Chaträume damit finden und moderieren.
|
Sie können die Chaträume damit finden und moderieren.
|
||||||
|
|
||||||
|
## Federation
|
||||||
|
|
||||||
|
Following settings concern the fedration with other Peertube instances,
|
||||||
|
and other fediverse softwares.
|
||||||
|
|
||||||
|
### Don't display remote chats
|
||||||
|
|
||||||
|
By checking this setting, your instance will never display chats from remote videos.
|
||||||
|
|
||||||
|
### Don't publish chat information
|
||||||
|
|
||||||
|
By checking this setting, your instance will not publish chat information on the fediverse.
|
||||||
|
Remote Peertube instances will not be aware that they are chat rooms associated to your videos.
|
||||||
|
|
||||||
|
**Please note**: if you already had chats in progress, it is possible that the information has already been published.
|
||||||
|
You will have to wait for the next video update before the information is unpublished.
|
||||||
|
Also, if you disable this setting, you'll have to wait for the videos to be updated before the information are
|
||||||
|
published again. This update happens among others when a live event resumes or stops.
|
||||||
|
|
||||||
|
**Please note**: this setting only affects the publication of information via the ActivityPub protocol.
|
||||||
|
It will not prevent a remote application from otherwise detecting the presence of chats, and trying to connect to it.
|
||||||
|
|
||||||
## Chat behaviour (Chatverhalten)
|
## Chat behaviour (Chatverhalten)
|
||||||
|
|
||||||
### Room type (Raumtyp)
|
### Room type (Raumtyp)
|
||||||
|
@ -12,6 +12,28 @@ This section describes the plugin settings page.
|
|||||||
When pressing the «List rooms» button, all existing chatrooms will be listed.
|
When pressing the «List rooms» button, all existing chatrooms will be listed.
|
||||||
You can then find them and moderated them.
|
You can then find them and moderated them.
|
||||||
|
|
||||||
|
## Federation
|
||||||
|
|
||||||
|
Following settings concern the fedration with other Peertube instances,
|
||||||
|
and other fediverse softwares.
|
||||||
|
|
||||||
|
### Don't display remote chats
|
||||||
|
|
||||||
|
By checking this setting, your instance will never display chats from remote videos.
|
||||||
|
|
||||||
|
### Don't publish chat information
|
||||||
|
|
||||||
|
By checking this setting, your instance will not publish chat information on the fediverse.
|
||||||
|
Remote Peertube instances will not be aware that they are chat rooms associated to your videos.
|
||||||
|
|
||||||
|
**Please note**: if you already had chats in progress, it is possible that the information has already been published.
|
||||||
|
You will have to wait for the next video update before the information is unpublished.
|
||||||
|
Also, if you disable this setting, you'll have to wait for the videos to be updated before the information are
|
||||||
|
published again. This update happens among others when a live event resumes or stops.
|
||||||
|
|
||||||
|
**Please note**: this setting only affects the publication of information via the ActivityPub protocol.
|
||||||
|
It will not prevent a remote application from otherwise detecting the presence of chats, and trying to connect to it.
|
||||||
|
|
||||||
## Chat behaviour
|
## Chat behaviour
|
||||||
|
|
||||||
### Room type
|
### Room type
|
||||||
|
Loading…
x
Reference in New Issue
Block a user