Merge branch 'develop' into main

This commit is contained in:
John Livingston 2021-12-11 17:50:50 +01:00 committed by GitHub
commit 9910a60a8d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 79 additions and 21 deletions

View File

@ -1,12 +1,25 @@
# Changelog
## (unreleased yet)
### Fixes
* Fix spanish translation.
* Hide secret keys in diagnostic tool.
## v5.0.2
### Fixes
* Fix some cases where the chat immediatly close (Peertube events are not fired in the good order).
## v5.0.1
### Breaking changes
* If you have some CSS customization for the plugin, it may be broken.
* Auto color detection can have bad result for some Peertube themes. If so, you can disable it in the settings.
* Note: if updating the plugin to v5.0.1 fails with an error like `Cannot find module 'validate-color'`, try to restart peertube, then install/update the plugin. See https://github.com/Chocobozzz/PeerTube/issues/4593
* Note: if updating the plugin to v5.0.1 fails with an error like `Cannot find module 'validate-color'`, try to restart peertube, then install/update the plugin. See <https://github.com/Chocobozzz/PeerTube/issues/4593>
### Features

View File

@ -39,3 +39,4 @@ This roadmap is given as an indication. It will be updated as we go along accord
[ ] | Builtin Prosody | Add on option to limit webchat to registered users.
[x] | Builtin Prosody (or all modes?) | Offer a way for users to have a webchat per channel. See [#59](https://github.com/JohnXLivingston/peertube-plugin-livechat/issues/58). | v4.0.0
[ ] | Common | Handle federation: if video is remote, then try to check if the plugin is installed on the instance, and open it.
[ ] | Builtin Prosody | Moderation Bot.

View File

@ -5,6 +5,15 @@ async function register ({ peertubeHelpers, registerHook, registerVideoField }:
handler: () => {
const container = document.querySelector('#peertube-plugin-livechat-container')
if (container) {
const url = container.getAttribute('peertube-plugin-livechat-current-url')
if (url && url === window.location.href) {
console.warn(
'[peertube-plugin-livechat navigation-end] ' +
'It seems that action:router.navigation-end was called after action:video-watch.video.loaded. ' +
'No removing the chat from the DOM.'
)
return
}
container.remove()
}
}

View File

@ -289,6 +289,7 @@ function register ({ registerHook, peertubeHelpers }: RegisterOptions): void {
container = document.createElement('div')
container.setAttribute('id', 'peertube-plugin-livechat-container')
container.setAttribute('peertube-plugin-livechat-state', 'initializing')
container.setAttribute('peertube-plugin-livechat-current-url', window.location.href)
placeholder.append(container)
peertubeHelpers.getSettings().then((s: any) => {

View File

@ -116,3 +116,9 @@ If the video is local (not from a remote Peertube), the video owner will be admi
You can use [ConverseJS moderation commands](https://conversejs.org/docs/html/features.html#moderating-chatrooms) to moderate the room.
When you open the chat room in full screen, there will also be a menu with dedicated commands on the top right.
## Advanced usages
### OBS Overlay using Matterbridge
Here is a tutorial to use Matterbridge with the plugin: <https://gitlab.com/refrac/obs-matterbridge-overlay/-/blob/master/documentation/peertube.md>

View File

@ -1,7 +1,7 @@
{
"Open chat": "Abrir el chat.",
"Open chat in a new window": "Abrir el chat en otra ventana.",
"Close chat": "Cerrar el chat.",
"Use chat": "Habilitar el chat.",
"If enabled, there will be a chat next to the video.": "Activado, abre el chat junto al vídeo."
"Open chat": "Abrir el chat",
"Open chat in a new window": "Abrir el chat en otra ventana",
"Close chat": "Cerrar el chat",
"Use chat": "Habilitar el chat",
"If enabled, there will be a chat next to the video.": "Activado, abre el chat junto al vídeo"
}

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "peertube-plugin-livechat",
"version": "5.0.1",
"version": "5.0.2",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@ -1,7 +1,7 @@
{
"name": "peertube-plugin-livechat",
"description": "PeerTube plugin livechat: offers a way to embed a chat system into Peertube.",
"version": "5.0.1",
"version": "5.0.2",
"author": {
"name": "John Livingston",
"url": "https://github.com/JohnXLivingston"

View File

@ -1,4 +1,4 @@
import { getProsodyConfig, getWorkingDir } from '../prosody/config'
import { getProsodyConfig, getProsodyConfigContentForDiagnostic, getWorkingDir } from '../prosody/config'
import { getProsodyAbout, testProsodyCorrectlyRunning } from '../prosody/ctl'
import { newResult, TestResult } from './utils'
import { getAPIKey } from '../apikey'
@ -58,7 +58,10 @@ export async function diagProsody (test: string, options: RegisterServerOptions)
result.debug.push({
title: 'Current prosody configuration',
message: actualContent
// we have to hide secret keys and other values.
// But here, we haven't them for actualContent.
// So we will use values in wantedConfig, hopping it is enough.
message: getProsodyConfigContentForDiagnostic(wantedConfig, actualContent)
})
const wantedContent = wantedConfig.content
@ -68,7 +71,8 @@ export async function diagProsody (test: string, options: RegisterServerOptions)
result.messages.push('Prosody configuration file content is not correct.')
result.debug.push({
title: 'Prosody configuration should be',
message: wantedContent
// we have to hide secret keys and other values:
message: getProsodyConfigContentForDiagnostic(wantedConfig)
})
return result
}

View File

@ -72,25 +72,38 @@ interface ProsodyConfig {
roomType: 'video' | 'channel'
logByDefault: boolean
logExpiration: ConfigLogExpiration
valuesToHideInDiagnostic: {[key: string]: string}
}
async function getProsodyConfig (options: RegisterServerOptions): Promise<ProsodyConfig> {
const logger = options.peertubeHelpers.logger
logger.debug('Calling getProsodyConfig')
const port = (await options.settingsManager.getSetting('prosody-port') as string) || '52800'
const settings = await options.settingsManager.getSettings([
'prosody-port',
'prosody-muc-log-by-default',
'prosody-muc-expiration',
'prosody-c2s',
'prosody-room-type',
'prosody-peertube-uri',
'prosody-c2s-port'
])
const valuesToHideInDiagnostic: {[key: string]: string} = {}
const port = (settings['prosody-port'] as string) || '52800'
if (!/^\d+$/.test(port)) {
throw new Error('Invalid port')
}
const logByDefault = (await options.settingsManager.getSetting('prosody-muc-log-by-default') as boolean) ?? true
const logExpirationSetting =
(await options.settingsManager.getSetting('prosody-muc-expiration') as string) ?? DEFAULTLOGEXPIRATION
const enableC2s = (await options.settingsManager.getSetting('prosody-c2s') as boolean) || false
const logByDefault = (settings['prosody-muc-log-by-default'] as boolean) ?? true
const logExpirationSetting = (settings['prosody-muc-expiration'] as string) ?? DEFAULTLOGEXPIRATION
const enableC2s = (settings['prosody-c2s'] as boolean) || false
const prosodyDomain = await getProsodyDomain(options)
const paths = await getProsodyFilePaths(options)
const roomType = (await options.settingsManager.getSetting('prosody-room-type')) === 'channel' ? 'channel' : 'video'
const roomType = settings['prosody-room-type'] === 'channel' ? 'channel' : 'video'
const apikey = await getAPIKey(options)
let baseApiUrl = await options.settingsManager.getSetting('prosody-peertube-uri') as string
valuesToHideInDiagnostic.APIKey = apikey
let baseApiUrl = settings['prosody-peertube-uri'] as string
if (baseApiUrl && !/^https?:\/\/[a-z0-9.-_]+(?::\d+)?$/.test(baseApiUrl)) {
throw new Error('Invalid prosody-peertube-uri')
}
@ -109,7 +122,7 @@ async function getProsodyConfig (options: RegisterServerOptions): Promise<Prosod
config.useMucHttpDefault(roomApiUrl)
if (enableC2s) {
const c2sPort = (await options.settingsManager.getSetting('prosody-c2s-port') as string) || '52822'
const c2sPort = (settings['prosody-c2s-port'] as string) || '52822'
if (!/^\d+$/.test(c2sPort)) {
throw new Error('Invalid c2s port')
}
@ -149,7 +162,8 @@ async function getProsodyConfig (options: RegisterServerOptions): Promise<Prosod
host: prosodyDomain,
roomType,
logByDefault,
logExpiration
logExpiration,
valuesToHideInDiagnostic
}
}
@ -222,10 +236,20 @@ function readLogExpiration (options: RegisterServerOptions, logExpiration: strin
}
}
function getProsodyConfigContentForDiagnostic (config: ProsodyConfig, content?: string): string {
let r: string = content ?? config.content
for (const key in config.valuesToHideInDiagnostic) {
// replaceAll not available, using trick:
r = r.split(config.valuesToHideInDiagnostic[key]).join(`***${key}***`)
}
return r
}
export {
getProsodyConfig,
getWorkingDir,
ensureWorkingDir,
getProsodyFilePaths,
writeProsodyConfig
writeProsodyConfig,
getProsodyConfigContentForDiagnostic
}