Prosody mode only:
Removing old modes (ConverseJS and External URI). Work in progress.
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
import type { RegisterClientOptions } from '@peertube/peertube-types/client'
|
||||
import type { Video } from '@peertube/peertube-types'
|
||||
import type { ChatType, ProsodyListRoomsResult } from 'shared/lib/types'
|
||||
import type { ProsodyListRoomsResult } from 'shared/lib/types'
|
||||
|
||||
interface ActionPluginSettingsParams {
|
||||
npmName: string
|
||||
@ -202,56 +202,13 @@ function register ({ registerHook, registerSettingsScript, peertubeHelpers }: Re
|
||||
isSettingHidden: options => {
|
||||
const name = options.setting.name
|
||||
switch (name) {
|
||||
case 'chat-type-help-disabled':
|
||||
return options.formValues['chat-type'] !== ('disabled' as ChatType)
|
||||
case 'prosody-room-type':
|
||||
case 'prosody-port':
|
||||
case 'prosody-peertube-uri':
|
||||
case 'chat-type-help-builtin-prosody':
|
||||
case 'prosody-list-rooms':
|
||||
case 'prosody-advanced':
|
||||
case 'prosody-muc-log-by-default':
|
||||
case 'prosody-muc-expiration':
|
||||
case 'prosody-c2s':
|
||||
case 'prosody-components':
|
||||
case 'chat-share-url':
|
||||
return options.formValues['chat-type'] !== ('builtin-prosody' as ChatType)
|
||||
case 'prosody-c2s-port':
|
||||
return !(
|
||||
options.formValues['chat-type'] === ('builtin-prosody' as ChatType) &&
|
||||
options.formValues['prosody-c2s'] === true
|
||||
)
|
||||
return options.formValues['prosody-c2s'] !== true
|
||||
case 'prosody-components-port':
|
||||
case 'prosody-components-list':
|
||||
return !(
|
||||
options.formValues['chat-type'] === ('builtin-prosody' as ChatType) &&
|
||||
options.formValues['prosody-components'] === true
|
||||
)
|
||||
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 'converse-advanced':
|
||||
case 'converse-theme':
|
||||
return !(
|
||||
options.formValues['chat-type'] === ('builtin-converse' as ChatType) ||
|
||||
options.formValues['chat-type'] === ('builtin-prosody' as ChatType)
|
||||
)
|
||||
return options.formValues['prosody-components'] !== true
|
||||
case 'converse-autocolors':
|
||||
return !(
|
||||
(
|
||||
options.formValues['chat-type'] === ('builtin-converse' as ChatType) ||
|
||||
options.formValues['chat-type'] === ('builtin-prosody' as ChatType)
|
||||
) &&
|
||||
options.formValues['converse-theme'] === 'peertube'
|
||||
)
|
||||
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'
|
||||
return options.formValues['converse-theme'] !== 'peertube'
|
||||
case 'chat-per-live-video-warning':
|
||||
return !(options.formValues['chat-all-lives'] === true && options.formValues['chat-per-live-video'] === true)
|
||||
}
|
||||
|
@ -253,20 +253,15 @@ function register (registerOptions: RegisterClientOptions): void {
|
||||
}
|
||||
|
||||
let showShareUrlButton: boolean = false
|
||||
if (settings['chat-type'] === 'builtin-prosody') {
|
||||
// The share url functionality should be technically possible for other modes
|
||||
// than builtin-prosody. But it is too difficult to maintain.
|
||||
// So I choose to enable it only for builtin-prosody.
|
||||
|
||||
const chatShareUrl = settings['chat-share-url'] ?? ''
|
||||
if (chatShareUrl === 'everyone') {
|
||||
showShareUrlButton = true
|
||||
} else if (chatShareUrl === 'owner') {
|
||||
showShareUrlButton = guessIsMine(registerOptions, video)
|
||||
} else if (chatShareUrl === 'owner+moderators') {
|
||||
showShareUrlButton = guessIsMine(registerOptions, video) || guessIamIModerator(registerOptions)
|
||||
}
|
||||
const chatShareUrl = settings['chat-share-url'] ?? ''
|
||||
if (chatShareUrl === 'everyone') {
|
||||
showShareUrlButton = true
|
||||
} else if (chatShareUrl === 'owner') {
|
||||
showShareUrlButton = guessIsMine(registerOptions, video)
|
||||
} else if (chatShareUrl === 'owner+moderators') {
|
||||
showShareUrlButton = guessIsMine(registerOptions, video) || guessIamIModerator(registerOptions)
|
||||
}
|
||||
|
||||
insertChatDom(container as HTMLElement, video, !!settings['chat-open-blank'], showShareUrlButton).then(() => {
|
||||
if (settings['chat-auto-display']) {
|
||||
openChat(video)
|
||||
|
@ -106,7 +106,7 @@ async function shareChatUrl (registerOptions: RegisterClientOptions, settings: a
|
||||
readonlyOptions.append(transparentLabelEl)
|
||||
|
||||
let autoColors
|
||||
if (isAutoColorsAvailable(settings['chat-type'], settings['converse-theme'])) {
|
||||
if (isAutoColorsAvailable(settings['converse-theme'])) {
|
||||
const label = document.createElement('label')
|
||||
label.innerText = labelAutocolors
|
||||
autoColors = document.createElement('input')
|
||||
|
@ -1,6 +1,5 @@
|
||||
import type { RegisterClientOptions } from '@peertube/peertube-types/client'
|
||||
import type { Video } from '@peertube/peertube-types'
|
||||
import type { ChatType } from 'shared/lib/types'
|
||||
import { AutoColors, isAutoColorsAvailable } from 'shared/lib/autocolors'
|
||||
import { logger } from './logger'
|
||||
import { computeAutoColors } from './colors'
|
||||
@ -32,41 +31,15 @@ function getIframeUri (
|
||||
logger.error('Settings are not initialized, too soon to compute the iframeUri')
|
||||
return null
|
||||
}
|
||||
let iframeUriStr = ''
|
||||
const chatType: ChatType = (settings['chat-type'] ?? 'disabled') as ChatType
|
||||
if (chatType === 'builtin-prosody' || chatType === 'builtin-converse') {
|
||||
// Using the builtin converseJS
|
||||
iframeUriStr = getBaseRoute(registerOptions, uriOptions.permanent)
|
||||
iframeUriStr += '/webchat/room/' + encodeURIComponent(video.uuid)
|
||||
} else if (chatType === 'external-uri') {
|
||||
iframeUriStr = settings['chat-uri'] || ''
|
||||
iframeUriStr = iframeUriStr.replace(/{{VIDEO_UUID}}/g, encodeURIComponent(video.uuid))
|
||||
if (iframeUriStr.includes('{{CHANNEL_ID}}')) {
|
||||
if (!video.channel || !video.channel.id) {
|
||||
logger.error('Missing channel info in video object.')
|
||||
return null
|
||||
}
|
||||
iframeUriStr = iframeUriStr.replace(/{{CHANNEL_ID}}/g, encodeURIComponent(video.channel.id))
|
||||
}
|
||||
if (!/^https?:\/\//.test(iframeUriStr)) {
|
||||
logger.error('The webchaturi must begin with https://')
|
||||
return null
|
||||
}
|
||||
} else {
|
||||
logger.error('Chat disabled.')
|
||||
return null
|
||||
}
|
||||
if (iframeUriStr === '') {
|
||||
logger.error('No iframe uri')
|
||||
return null
|
||||
}
|
||||
let iframeUriStr = getBaseRoute(registerOptions, uriOptions.permanent)
|
||||
iframeUriStr += '/webchat/room/' + encodeURIComponent(video.uuid)
|
||||
|
||||
const iFrameUri = new URL(iframeUriStr, window.location.origin)
|
||||
|
||||
if (
|
||||
!uriOptions.ignoreAutoColors &&
|
||||
settings['converse-autocolors'] &&
|
||||
isAutoColorsAvailable(settings['chat-type'] as ChatType, settings['converse-theme'])
|
||||
isAutoColorsAvailable(settings['converse-theme'])
|
||||
) {
|
||||
logger.info('We have to try to compute autocolors.')
|
||||
try {
|
||||
|
Reference in New Issue
Block a user