Chat Federation: don't display chat when anonymous connections are disabled
This commit is contained in:
parent
a07a7a6ce8
commit
0ce95d4a39
@ -1,5 +1,6 @@
|
||||
import type { RegisterServerOptions, Video, MVideoThumbnail } from '@peertube/peertube-types'
|
||||
import { getVideoLiveChatInfos } from './federation/storage'
|
||||
import { anonymousConnectionInfos } from './federation/connection-infos'
|
||||
|
||||
async function initCustomFields (options: RegisterServerOptions): Promise<void> {
|
||||
const registerHook = options.registerHook
|
||||
@ -83,6 +84,10 @@ async function fillVideoRemoteLiveChat (
|
||||
const infos = await getVideoLiveChatInfos(options, video)
|
||||
if (!infos) { return }
|
||||
|
||||
// We must check if there is a compatible connection protocol...
|
||||
// For now, the only that is implemetied is by using a remote anonymous account.
|
||||
if (!anonymousConnectionInfos(infos)) { return }
|
||||
|
||||
const v: LiveChatCustomFieldsVideo = video
|
||||
if (!v.pluginData) v.pluginData = {}
|
||||
v.pluginData['livechat-remote'] = true
|
||||
|
@ -29,7 +29,8 @@ async function videoBuildJSONLD (
|
||||
'chat-videos-list',
|
||||
'disable-websocket',
|
||||
'prosody-room-type',
|
||||
'federation-dont-publish-remotely'
|
||||
'federation-dont-publish-remotely',
|
||||
'chat-no-anonymous'
|
||||
])
|
||||
|
||||
if (settings['federation-dont-publish-remotely']) {
|
||||
@ -66,22 +67,25 @@ async function videoBuildJSONLD (
|
||||
roomJID = `${video.uuid}@room.${prosodyDomain}`
|
||||
}
|
||||
|
||||
const links: LiveChatJSONLDLink[] = [{
|
||||
type: 'xmpp-bosh-anonymous',
|
||||
url: canonicalizePluginUri(options, getBoshUri(options), { removePluginVersion: true }),
|
||||
jid: userJID
|
||||
}]
|
||||
if (!settings['disable-websocket']) {
|
||||
const wsUri = getWSUri(options)
|
||||
if (wsUri) {
|
||||
links.push({
|
||||
type: 'xmpp-websocket-anonymous',
|
||||
url: canonicalizePluginUri(options, wsUri, {
|
||||
removePluginVersion: true,
|
||||
protocol: 'ws'
|
||||
}),
|
||||
jid: userJID
|
||||
})
|
||||
const links: LiveChatJSONLDLink[] = []
|
||||
if (!settings['chat-no-anonymous']) {
|
||||
links.push({
|
||||
type: 'xmpp-bosh-anonymous',
|
||||
url: canonicalizePluginUri(options, getBoshUri(options), { removePluginVersion: true }),
|
||||
jid: userJID
|
||||
})
|
||||
if (!settings['disable-websocket']) {
|
||||
const wsUri = getWSUri(options)
|
||||
if (wsUri) {
|
||||
links.push({
|
||||
type: 'xmpp-websocket-anonymous',
|
||||
url: canonicalizePluginUri(options, wsUri, {
|
||||
removePluginVersion: true,
|
||||
protocol: 'ws'
|
||||
}),
|
||||
jid: userJID
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user