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 type { RegisterServerOptions, Video, MVideoThumbnail } from '@peertube/peertube-types'
|
||||||
import { getVideoLiveChatInfos } from './federation/storage'
|
import { getVideoLiveChatInfos } from './federation/storage'
|
||||||
|
import { anonymousConnectionInfos } from './federation/connection-infos'
|
||||||
|
|
||||||
async function initCustomFields (options: RegisterServerOptions): Promise<void> {
|
async function initCustomFields (options: RegisterServerOptions): Promise<void> {
|
||||||
const registerHook = options.registerHook
|
const registerHook = options.registerHook
|
||||||
@ -83,6 +84,10 @@ async function fillVideoRemoteLiveChat (
|
|||||||
const infos = await getVideoLiveChatInfos(options, video)
|
const infos = await getVideoLiveChatInfos(options, video)
|
||||||
if (!infos) { return }
|
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
|
const v: LiveChatCustomFieldsVideo = video
|
||||||
if (!v.pluginData) v.pluginData = {}
|
if (!v.pluginData) v.pluginData = {}
|
||||||
v.pluginData['livechat-remote'] = true
|
v.pluginData['livechat-remote'] = true
|
||||||
|
@ -29,7 +29,8 @@ async function videoBuildJSONLD (
|
|||||||
'chat-videos-list',
|
'chat-videos-list',
|
||||||
'disable-websocket',
|
'disable-websocket',
|
||||||
'prosody-room-type',
|
'prosody-room-type',
|
||||||
'federation-dont-publish-remotely'
|
'federation-dont-publish-remotely',
|
||||||
|
'chat-no-anonymous'
|
||||||
])
|
])
|
||||||
|
|
||||||
if (settings['federation-dont-publish-remotely']) {
|
if (settings['federation-dont-publish-remotely']) {
|
||||||
@ -66,22 +67,25 @@ async function videoBuildJSONLD (
|
|||||||
roomJID = `${video.uuid}@room.${prosodyDomain}`
|
roomJID = `${video.uuid}@room.${prosodyDomain}`
|
||||||
}
|
}
|
||||||
|
|
||||||
const links: LiveChatJSONLDLink[] = [{
|
const links: LiveChatJSONLDLink[] = []
|
||||||
type: 'xmpp-bosh-anonymous',
|
if (!settings['chat-no-anonymous']) {
|
||||||
url: canonicalizePluginUri(options, getBoshUri(options), { removePluginVersion: true }),
|
links.push({
|
||||||
jid: userJID
|
type: 'xmpp-bosh-anonymous',
|
||||||
}]
|
url: canonicalizePluginUri(options, getBoshUri(options), { removePluginVersion: true }),
|
||||||
if (!settings['disable-websocket']) {
|
jid: userJID
|
||||||
const wsUri = getWSUri(options)
|
})
|
||||||
if (wsUri) {
|
if (!settings['disable-websocket']) {
|
||||||
links.push({
|
const wsUri = getWSUri(options)
|
||||||
type: 'xmpp-websocket-anonymous',
|
if (wsUri) {
|
||||||
url: canonicalizePluginUri(options, wsUri, {
|
links.push({
|
||||||
removePluginVersion: true,
|
type: 'xmpp-websocket-anonymous',
|
||||||
protocol: 'ws'
|
url: canonicalizePluginUri(options, wsUri, {
|
||||||
}),
|
removePluginVersion: true,
|
||||||
jid: userJID
|
protocol: 'ws'
|
||||||
})
|
}),
|
||||||
|
jid: userJID
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user