Replacing old settings by chat-type.
This commit is contained in:
@ -1,7 +1,4 @@
|
||||
import type { ChatType } from 'shared/lib/types'
|
||||
const prosodySettings = ['prosody-port']
|
||||
const converseSettings = ['chat-server', 'chat-room', 'chat-bosh-uri', 'chat-ws-uri']
|
||||
const otherSettings: string[] = []
|
||||
|
||||
function register ({ registerSettingsScript }: RegisterOptions): void {
|
||||
registerSettingsScript({
|
||||
@ -10,30 +7,22 @@ function register ({ registerSettingsScript }: RegisterOptions): void {
|
||||
switch (name) {
|
||||
case 'chat-type-help-disabled':
|
||||
return options.formValues['chat-type'] !== ('disabled' as ChatType)
|
||||
case 'prosody-port':
|
||||
case 'chat-type-help-builtin-prosody':
|
||||
return options.formValues['chat-type'] !== ('builtin-prosody' as ChatType)
|
||||
case 'chat-server':
|
||||
case 'chat-room':
|
||||
case 'chat-bosh-uri':
|
||||
case 'chat-ws-uri':
|
||||
case 'chat-type-help-builtin-converse':
|
||||
return options.formValues['chat-type'] !== ('builtin-converse' as ChatType)
|
||||
case 'chat-uri':
|
||||
case 'chat-type-help-external-uri':
|
||||
return options.formValues['chat-type'] !== ('external-uri' as ChatType)
|
||||
case 'chat-style':
|
||||
return options.formValues['chat-type'] === 'disabled'
|
||||
}
|
||||
|
||||
// TODO: rewrite the code bellow.
|
||||
if (prosodySettings.includes(name)) {
|
||||
return options.formValues['chat-use-prosody'] !== true
|
||||
}
|
||||
if (name === 'chat-use-builtin') {
|
||||
return options.formValues['chat-use-prosody'] === true
|
||||
}
|
||||
if (converseSettings.includes(name)) {
|
||||
return options.formValues['chat-use-builtin'] !== true || options.formValues['chat-use-prosody'] === true
|
||||
}
|
||||
if (name === 'chat-uri') {
|
||||
return options.formValues['chat-use-prosody'] === true || options.formValues['chat-use-builtin'] === true
|
||||
}
|
||||
if (otherSettings.includes(name)) {
|
||||
return options.formValues['chat-use-builtin'] === true || options.formValues['chat-use-prosody'] === true
|
||||
}
|
||||
return false
|
||||
}
|
||||
})
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { videoHasWebchat } from 'shared/lib/video'
|
||||
import type { ChatType } from 'shared/lib/types'
|
||||
|
||||
interface VideoWatchLoadedHookOptions {
|
||||
videojs: any
|
||||
@ -33,10 +34,11 @@ function register ({ registerHook, peertubeHelpers }: RegisterOptions): void {
|
||||
return null
|
||||
}
|
||||
let iframeUri = ''
|
||||
if (settings['chat-use-prosody'] || settings['chat-use-builtin']) {
|
||||
const chatType: ChatType = (settings['chat-type'] ?? 'disabled') as ChatType
|
||||
if (chatType === 'builtin-prosody' || chatType === 'builtin-converse') {
|
||||
// Using the builtin converseJS
|
||||
iframeUri = getBaseRoute() + '/webchat/room/' + encodeURIComponent(uuid)
|
||||
} else if (!settings['chat-use-builtin']) {
|
||||
} else if (chatType === 'external-uri') {
|
||||
iframeUri = settings['chat-uri'] || ''
|
||||
iframeUri = iframeUri.replace(/{{VIDEO_UUID}}/g, encodeURIComponent(uuid))
|
||||
if (!/^https?:\/\//.test(iframeUri)) {
|
||||
@ -44,7 +46,7 @@ function register ({ registerHook, peertubeHelpers }: RegisterOptions): void {
|
||||
return null
|
||||
}
|
||||
} else {
|
||||
logger.error('Dont known which url use for the iframe.')
|
||||
logger.error('Chat disabled.')
|
||||
return null
|
||||
}
|
||||
if (iframeUri === '') {
|
||||
|
Reference in New Issue
Block a user