WIP on Prosody integration.

This commit is contained in:
John Livingston
2021-04-13 17:13:41 +02:00
parent 4690d97384
commit cc21305f6a
5 changed files with 164 additions and 22 deletions

View File

@ -1,5 +1,6 @@
import { getWorkingDir } from '../prosody/config'
import { getProsodyConfigContent, getProsodyConfigPath, getWorkingDir } from '../prosody/config'
import { newResult, TestResult } from './utils'
import * as fs from 'fs'
export async function diagProsody (test: string, options: RegisterServerOptions): Promise<TestResult> {
const result = newResult(test)
@ -13,6 +14,26 @@ export async function diagProsody (test: string, options: RegisterServerOptions)
return result
}
// Testing the prosody config file.
try {
const filePath = await getProsodyConfigPath(options)
await fs.promises.access(filePath, fs.constants.R_OK) // throw an error if file does not exist.
result.messages.push(`The prosody configuration file (${filePath}) exists`)
const actualContent = await fs.promises.readFile(filePath, {
encoding: 'utf-8'
})
const wantedContent = await getProsodyConfigContent(options)
if (actualContent === wantedContent) {
result.messages.push('Prosody configuration file content is correct.')
} else {
result.messages.push('Prosody configuration file content is not correct.')
return result
}
} catch (error) {
result.messages.push('Error when requiring the prosody config file: ' + (error as string))
return result
}
result.ok = true
return result
}