2021-04-12 15:53:12 +00:00
|
|
|
import { newResult, TestResult } from './utils'
|
|
|
|
|
2021-04-12 18:15:44 +00:00
|
|
|
export async function diagConverse (test: string, { settingsManager }: RegisterServerOptions): Promise<TestResult> {
|
2021-04-12 15:53:12 +00:00
|
|
|
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 (
|
2021-08-03 22:22:19 +00:00
|
|
|
!/^(\w|{{(VIDEO_UUID|CHANNEL_ID|CHANNEL_NAME)}})+@([a-z0-9.]+)+[a-z0-9]+$/
|
2021-04-12 15:53:12 +00:00
|
|
|
.test(chatRoom)
|
|
|
|
) {
|
|
|
|
result.messages.push(
|
|
|
|
'Invalid value for the webchat room: "' +
|
|
|
|
chatRoom +
|
|
|
|
'"'
|
|
|
|
)
|
|
|
|
isBuiltinError = true
|
|
|
|
} else {
|
2021-08-04 15:15:58 +00:00
|
|
|
result.messages.push('Chat room is correct and will be: ' + chatRoom)
|
2021-04-12 15:53:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|