2022-01-11 00:29:33 +00:00
|
|
|
import type { RegisterServerOptions } from '@peertube/peertube-types'
|
2021-04-12 15:53:12 +00:00
|
|
|
import { newResult, TestResult } from './utils'
|
|
|
|
|
2021-04-12 18:15:44 +00:00
|
|
|
export async function diagVideo (test: string, { settingsManager }: RegisterServerOptions): Promise<TestResult> {
|
2021-04-12 15:53:12 +00:00
|
|
|
const result = newResult(test)
|
|
|
|
result.label = 'Webchat activated on videos'
|
|
|
|
const videoSettings = await settingsManager.getSettings([
|
|
|
|
'chat-auto-display',
|
|
|
|
'chat-open-blank',
|
2021-06-08 16:08:58 +00:00
|
|
|
'chat-per-live-video',
|
2021-04-12 15:53:12 +00:00
|
|
|
'chat-all-lives',
|
|
|
|
'chat-all-non-lives',
|
|
|
|
'chat-videos-list'
|
|
|
|
])
|
|
|
|
if (videoSettings['chat-auto-display']) {
|
|
|
|
result.messages.push('Chat will open automatically')
|
|
|
|
} else {
|
|
|
|
result.messages.push('Chat will not open automatically')
|
|
|
|
}
|
|
|
|
|
|
|
|
if (videoSettings['chat-open-blank']) {
|
|
|
|
result.messages.push('Displaying «open in new window» button')
|
|
|
|
}
|
|
|
|
|
|
|
|
let atLeastOne: boolean = false
|
2021-06-08 16:08:58 +00:00
|
|
|
if (videoSettings['chat-per-live-video']) {
|
|
|
|
result.messages.push('Chat can be enabled on live videos.')
|
|
|
|
atLeastOne = true
|
|
|
|
}
|
2021-04-12 15:53:12 +00:00
|
|
|
if (videoSettings['chat-all-lives']) {
|
|
|
|
result.messages.push('Chat is enabled for all lives.')
|
|
|
|
atLeastOne = true
|
|
|
|
}
|
|
|
|
if (videoSettings['chat-all-non-lives']) {
|
|
|
|
result.messages.push('Chat is enabled for all non-lives.')
|
|
|
|
atLeastOne = true
|
|
|
|
}
|
|
|
|
if ((videoSettings['chat-videos-list'] ?? '') !== '') {
|
|
|
|
const lines = ((videoSettings['chat-videos-list'] ?? '') as string).split('\n')
|
|
|
|
for (let i = 0; i < lines.length; i++) {
|
|
|
|
if (/^\s*(-|\w)+\s*($|#)/.test(lines[i])) {
|
|
|
|
result.messages.push('Chat is activated for a specific videos.')
|
|
|
|
atLeastOne = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (atLeastOne) {
|
|
|
|
result.ok = true
|
2022-10-10 16:08:20 +00:00
|
|
|
result.next = 'prosody'
|
2021-04-12 15:53:12 +00:00
|
|
|
} else {
|
|
|
|
result.ok = false
|
|
|
|
result.messages.push('Chat is activate for no video.')
|
|
|
|
}
|
|
|
|
return result
|
|
|
|
}
|