Chat Federation: refactoring ActivityPub data:
The data format used by plugin v6.3.0 was not well suited. Here comes a new data format, with S2S informations. The plugin can automatically upgrade old format. It also continues to provide the old format, so than remote instance that did not update the plugin will still work.
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
import type { RegisterServerOptions, Video, MVideoThumbnail } from '@peertube/peertube-types'
|
||||
import { getVideoLiveChatInfos } from './federation/storage'
|
||||
import { anonymousConnectionInfos } from './federation/connection-infos'
|
||||
import { anonymousConnectionInfos, compatibleRemoteAuthenticatedConnectionEnabled } from './federation/connection-infos'
|
||||
|
||||
async function initCustomFields (options: RegisterServerOptions): Promise<void> {
|
||||
const registerHook = options.registerHook
|
||||
@ -84,9 +84,27 @@ async function fillVideoRemoteLiveChat (
|
||||
const infos = await getVideoLiveChatInfos(options, video)
|
||||
if (!infos) { return }
|
||||
|
||||
let ok: boolean = false
|
||||
// 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 }
|
||||
if (anonymousConnectionInfos(infos)) {
|
||||
// Connection ok using a remote anonymous account. That's enought.
|
||||
ok = true
|
||||
} else {
|
||||
const settings = await options.settingsManager.getSettings([
|
||||
'federation-no-remote-chat',
|
||||
'prosody-room-allow-s2s'
|
||||
])
|
||||
const canWebsocketS2S = !settings['federation-no-remote-chat']
|
||||
const canDirectS2S = !settings['federation-no-remote-chat'] && !!settings['prosody-room-allow-s2s']
|
||||
if (compatibleRemoteAuthenticatedConnectionEnabled(infos, canWebsocketS2S, canDirectS2S)) {
|
||||
// Even better, we can do a proper S2S connection!
|
||||
ok = true
|
||||
}
|
||||
}
|
||||
|
||||
if (!ok) {
|
||||
return
|
||||
}
|
||||
|
||||
const v: LiveChatCustomFieldsVideo = video
|
||||
if (!v.pluginData) v.pluginData = {}
|
||||
|
Reference in New Issue
Block a user