Prosody mode only:
Removing old modes (ConverseJS and External URI). Work in progress.
This commit is contained in:
@ -1,30 +0,0 @@
|
||||
import type { RegisterServerOptions } from '@peertube/peertube-types'
|
||||
import { newResult, TestResult } from './utils'
|
||||
import type { ChatType } from '../../../shared/lib/types'
|
||||
|
||||
export async function diagChatType (test: string, { settingsManager }: RegisterServerOptions): Promise<TestResult> {
|
||||
const result = newResult(test)
|
||||
const typeSettings = await settingsManager.getSettings([
|
||||
'chat-type'
|
||||
])
|
||||
result.label = 'Webchat type'
|
||||
const chatType: ChatType = (typeSettings['chat-type'] ?? 'disabled') as ChatType
|
||||
if (chatType === 'builtin-prosody') {
|
||||
result.messages.push('Using builtin Prosody')
|
||||
result.ok = true
|
||||
result.next = 'prosody'
|
||||
} else if (chatType === 'builtin-converse') {
|
||||
result.messages.push('Using builtin ConverseJS to connect to an external XMPP server')
|
||||
result.ok = true
|
||||
result.next = 'converse'
|
||||
} else if (chatType === 'external-uri') {
|
||||
result.messages.push('Using an external uri')
|
||||
result.ok = true
|
||||
result.next = 'use-uri'
|
||||
} else if (chatType === 'disabled') {
|
||||
result.messages.push('Webchat disabled')
|
||||
} else {
|
||||
result.messages.push('Unknown chat type value: ' + (chatType as string))
|
||||
}
|
||||
return result
|
||||
}
|
@ -1,77 +0,0 @@
|
||||
import type { RegisterServerOptions } from '@peertube/peertube-types'
|
||||
import { newResult, TestResult } from './utils'
|
||||
|
||||
export async function diagConverse (test: string, { settingsManager }: RegisterServerOptions): Promise<TestResult> {
|
||||
const result = newResult(test)
|
||||
result.label = 'Builtin ConverseJS on XMPP service'
|
||||
const builtinSettings = await settingsManager.getSettings([
|
||||
'chat-server',
|
||||
'chat-room',
|
||||
'chat-bosh-uri',
|
||||
'chat-ws-uri'
|
||||
])
|
||||
|
||||
let isBuiltinError = false
|
||||
|
||||
const chatServer: string = (builtinSettings['chat-server'] as string) || ''
|
||||
if (chatServer === '') {
|
||||
result.messages.push('Missing chat server configuration')
|
||||
isBuiltinError = true
|
||||
} else if (!/^([a-z0-9.]+)+[a-z0-9]+$/.test(chatServer)) {
|
||||
result.messages.push(
|
||||
'Invalid value for the webchat server: "' +
|
||||
chatServer +
|
||||
'"'
|
||||
)
|
||||
isBuiltinError = true
|
||||
} else {
|
||||
result.messages.push('Chat server is correct')
|
||||
}
|
||||
|
||||
const chatRoom: string = (builtinSettings['chat-room'] as string) || ''
|
||||
if (chatRoom === '') {
|
||||
result.messages.push('Missing chat room configuration')
|
||||
isBuiltinError = true
|
||||
} else if (
|
||||
!/^(\w|{{(VIDEO_UUID|CHANNEL_ID|CHANNEL_NAME)}})+@([a-z0-9.]+)+[a-z0-9]+$/
|
||||
.test(chatRoom)
|
||||
) {
|
||||
result.messages.push(
|
||||
'Invalid value for the webchat room: "' +
|
||||
chatRoom +
|
||||
'"'
|
||||
)
|
||||
isBuiltinError = true
|
||||
} else {
|
||||
result.messages.push('Chat room is correct and will be: ' + chatRoom)
|
||||
}
|
||||
|
||||
const chatBoshUri: string = (builtinSettings['chat-bosh-uri'] as string) || ''
|
||||
const chatWsUri: string = (builtinSettings['chat-ws-uri'] as string) || ''
|
||||
if (chatBoshUri === '' && chatWsUri === '') {
|
||||
result.messages.push('Missing BOSH or Websocket uri')
|
||||
isBuiltinError = true
|
||||
}
|
||||
if (chatBoshUri !== '') {
|
||||
if (!/^https?:\/\//.test(chatBoshUri)) {
|
||||
result.messages.push('Invalid BOSH Uri, should begin with https://')
|
||||
isBuiltinError = true
|
||||
} else {
|
||||
result.messages.push('Valid Bosh Uri')
|
||||
}
|
||||
}
|
||||
if (chatWsUri !== '') {
|
||||
if (!/^wss?:\/\//.test(chatWsUri)) {
|
||||
result.messages.push('Invalid Websocket Uri, should begin with wss://')
|
||||
isBuiltinError = true
|
||||
} else {
|
||||
result.messages.push('Valid Websocket Uri')
|
||||
}
|
||||
}
|
||||
|
||||
if (!isBuiltinError) {
|
||||
result.messages.push('Builtin converse is correctly configured')
|
||||
result.ok = true
|
||||
}
|
||||
return result
|
||||
}
|
@ -1,10 +1,7 @@
|
||||
import type { RegisterServerOptions } from '@peertube/peertube-types'
|
||||
import { diagBackend } from './backend'
|
||||
import { diagConverse } from './converse'
|
||||
import { diagChatType } from './chat-type'
|
||||
import { TestResult, newResult } from './utils'
|
||||
import { diagProsody } from './prosody'
|
||||
import { diagUri } from './uri'
|
||||
import { diagVideo } from './video'
|
||||
|
||||
export async function diag (test: string, options: RegisterServerOptions): Promise<TestResult> {
|
||||
@ -14,14 +11,8 @@ export async function diag (test: string, options: RegisterServerOptions): Promi
|
||||
result = await diagBackend(test, options)
|
||||
} else if (test === 'webchat-video') {
|
||||
result = await diagVideo(test, options)
|
||||
} else if (test === 'webchat-type') {
|
||||
result = await diagChatType(test, options)
|
||||
} else if (test === 'prosody') {
|
||||
result = await diagProsody(test, options)
|
||||
} else if (test === 'converse') {
|
||||
result = await diagConverse(test, options)
|
||||
} else if (test === 'use-uri') {
|
||||
result = await diagUri(test, options)
|
||||
} else {
|
||||
result = newResult(test)
|
||||
result.messages.push('Unknown test')
|
||||
|
@ -1,17 +0,0 @@
|
||||
import type { RegisterServerOptions } from '@peertube/peertube-types'
|
||||
import { newResult, TestResult } from './utils'
|
||||
|
||||
export async function diagUri (test: string, { settingsManager }: RegisterServerOptions): Promise<TestResult> {
|
||||
const result = newResult(test)
|
||||
result.label = 'External Webchat using an iframe'
|
||||
const settings = await settingsManager.getSettings([
|
||||
'chat-uri'
|
||||
])
|
||||
if (/^https:\/\//.test(settings['chat-uri'] as string)) {
|
||||
result.ok = true
|
||||
result.messages.push('Chat url will be: ' + (settings['chat-uri'] as string))
|
||||
} else {
|
||||
result.messages.push('Incorrect value for the uri (it does not start with https://)')
|
||||
}
|
||||
return result
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
type nextValue = 'backend' | 'webchat-video' | 'webchat-type' | 'prosody' | 'converse' | 'use-uri'
|
||||
type nextValue = 'backend' | 'webchat-video' | 'prosody'
|
||||
|
||||
interface MessageWithLevel {
|
||||
level: 'info' | 'warning' | 'error'
|
||||
|
@ -46,7 +46,7 @@ export async function diagVideo (test: string, { settingsManager }: RegisterServ
|
||||
}
|
||||
if (atLeastOne) {
|
||||
result.ok = true
|
||||
result.next = 'webchat-type'
|
||||
result.next = 'prosody'
|
||||
} else {
|
||||
result.ok = false
|
||||
result.messages.push('Chat is activate for no video.')
|
||||
|
Reference in New Issue
Block a user