2024-05-23 09:42:14 +00:00
|
|
|
// SPDX-FileCopyrightText: 2024 John Livingston <https://www.john-livingston.fr/>
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2022-01-11 00:29:33 +00:00
|
|
|
import type { RegisterServerOptions } from '@peertube/peertube-types'
|
2021-04-12 15:53:12 +00:00
|
|
|
import { diagBackend } from './backend'
|
|
|
|
import { TestResult, newResult } from './utils'
|
2023-04-13 13:41:46 +00:00
|
|
|
import { diagDebug } from './debug'
|
2021-04-12 15:53:12 +00:00
|
|
|
import { diagProsody } from './prosody'
|
|
|
|
import { diagVideo } from './video'
|
2024-04-22 11:03:31 +00:00
|
|
|
import { diagExternalAuthOIDC } from './external-auth-oidc'
|
2023-07-26 16:16:30 +00:00
|
|
|
import { helpUrl } from '../../../shared/lib/help'
|
2021-04-12 15:53:12 +00:00
|
|
|
|
2021-04-12 18:15:44 +00:00
|
|
|
export async function diag (test: string, options: RegisterServerOptions): Promise<TestResult> {
|
2021-04-12 15:53:12 +00:00
|
|
|
let result: TestResult
|
|
|
|
|
|
|
|
if (test === 'backend') {
|
2021-04-12 18:15:44 +00:00
|
|
|
result = await diagBackend(test, options)
|
2023-04-13 13:41:46 +00:00
|
|
|
} else if (test === 'debug') {
|
|
|
|
result = await diagDebug(test, options)
|
2021-04-12 15:53:12 +00:00
|
|
|
} else if (test === 'webchat-video') {
|
2021-04-12 18:15:44 +00:00
|
|
|
result = await diagVideo(test, options)
|
2021-04-12 15:53:12 +00:00
|
|
|
} else if (test === 'prosody') {
|
2021-04-12 18:15:44 +00:00
|
|
|
result = await diagProsody(test, options)
|
2024-04-15 16:29:09 +00:00
|
|
|
} else if (test === 'external-auth-custom-oidc') {
|
2024-04-22 11:03:31 +00:00
|
|
|
result = await diagExternalAuthOIDC(test, options, 'custom', 'external-auth-google-oidc')
|
|
|
|
} else if (test === 'external-auth-google-oidc') {
|
|
|
|
result = await diagExternalAuthOIDC(test, options, 'google', 'external-auth-facebook-oidc')
|
|
|
|
} else if (test === 'external-auth-facebook-oidc') {
|
|
|
|
result = await diagExternalAuthOIDC(test, options, 'facebook', 'everything-ok')
|
2023-07-26 16:16:30 +00:00
|
|
|
} else if (test === 'everything-ok') {
|
|
|
|
result = newResult(test)
|
|
|
|
result.label = 'Everything seems fine'
|
|
|
|
result.messages = [{
|
|
|
|
level: 'info',
|
|
|
|
message: 'If you still encounter issues with the plugin, check this documentation page:',
|
|
|
|
help: {
|
|
|
|
text: 'Plugin troubleshooting',
|
|
|
|
url: helpUrl({
|
|
|
|
page: 'documentation/installation/troubleshooting'
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}]
|
|
|
|
result.ok = true
|
2021-04-12 15:53:12 +00:00
|
|
|
} else {
|
|
|
|
result = newResult(test)
|
|
|
|
result.messages.push('Unknown test')
|
|
|
|
}
|
|
|
|
|
|
|
|
return result
|
|
|
|
}
|