Diagnostic: check prosody version.

This commit is contained in:
John Livingston 2021-05-02 16:16:19 +02:00
parent e1b08ce025
commit f11fec7c97
3 changed files with 44 additions and 3 deletions

View File

@ -1,6 +1,11 @@
interface MessageWithLevel {
level: 'info' | 'warning' | 'error'
message: string
}
interface Result {
label?: string
messages: string[]
messages: Array<MessageWithLevel | string>
debug?: Array<{
title: string
message: string
@ -48,7 +53,19 @@ function launchTests (): void {
const messageUl = document.createElement('ul')
for (let i = 0; i < result.messages.length; i++) {
const messageLi = document.createElement('li')
messageLi.textContent = result.messages[i]
const message = result.messages[i]
if (typeof message === 'string') {
messageLi.textContent = message
} else {
const messageSpan = document.createElement('span')
if (message.level === 'warning') {
messageSpan.style.color = 'orange'
} else if (message.level === 'error') {
messageSpan.style.color = 'red'
}
messageSpan.textContent = message.message
messageLi.append(messageSpan)
}
messageUl.append(messageLi)
}
li.append(messageUl)

View File

@ -67,6 +67,26 @@ export async function diagProsody (test: string, options: RegisterServerOptions)
return result
}
const versionMatches = about.match(/^Prosody\s*(\d+)\.(\d+)\.(\d+)\s*$/mi)
if (!versionMatches) {
result.messages.push({
level: 'error',
message: 'Errors: cant find prosody version.'
})
return result
} else {
const major = versionMatches[1]
const minor = versionMatches[2]
const patch = versionMatches[3]
result.messages.push(`Prosody version is ${major}.${minor}.${patch}`)
if (major !== '0' && minor !== '11') {
result.messages.push({
level: parseInt(minor) < 11 ? 'error' : 'warning',
message: 'Warning: recommended Prosody version is 0.11.x'
})
}
}
result.ok = true
return result
}

View File

@ -1,8 +1,12 @@
type nextValue = 'backend' | 'webchat-video' | 'webchat-type' | 'prosody' | 'converse' | 'use-uri'
interface MessageWithLevel {
level: 'info' | 'warning' | 'error'
message: string
}
export interface TestResult {
label?: string
messages: string[]
messages: Array<string | MessageWithLevel>
debug: Array<{
title: string
message: string