Chat Federation: using S2S if available.

* if both local and remote instance have external XMPP connections enabled, the user joins the remote room with his local account
* some code refactoring (builtin.ts)

Note: documentation and settings descriptions are to do.

Related to #112
This commit is contained in:
John Livingston
2023-05-04 19:14:23 +02:00
parent 1003378b24
commit 3bc05d88df
16 changed files with 483 additions and 285 deletions

View File

@ -31,6 +31,17 @@ function anonymousConnectionInfos (livechatInfos: LiveChatJSONLDAttribute | fals
return r
}
export {
anonymousConnectionInfos
function remoteAuthenticatedConnectionEnabled (livechatInfos: LiveChatJSONLDAttribute | false): boolean {
if (!livechatInfos) { return false }
if (!livechatInfos.links) { return false }
if (livechatInfos.type !== 'xmpp') { return false }
for (const link of livechatInfos.links) {
if (link.type === 'xmpp-s2s') { return true }
}
return false
}
export {
anonymousConnectionInfos,
remoteAuthenticatedConnectionEnabled
}

View File

@ -31,7 +31,8 @@ async function videoBuildJSONLD (
'disable-websocket',
'prosody-room-type',
'federation-dont-publish-remotely',
'chat-no-anonymous'
'chat-no-anonymous',
'prosody-room-allow-s2s'
])
if (settings['federation-dont-publish-remotely']) {
@ -70,6 +71,11 @@ async function videoBuildJSONLD (
}
const links: LiveChatJSONLDLink[] = []
if (settings['prosody-room-allow-s2s']) {
links.push({
type: 'xmpp-s2s'
})
}
if (!settings['chat-no-anonymous']) {
links.push({
type: 'xmpp-bosh-anonymous',

View File

@ -36,6 +36,11 @@ function sanitizePeertubeLiveChatInfos (chatInfos: any): LiveChatJSONLDAttribute
url: link.url
})
}
if (link.type === 'xmpp-s2s') {
r.links.push({
type: link.type
})
}
}
return r
}

View File

@ -4,6 +4,10 @@ interface VideoBuildResultContext {
video: MVideoAP
}
interface LiveChatJSONLDS2SLink {
type: 'xmpp-s2s'
}
interface LiveChatJSONLDAnonymousWebsocketLink {
type: 'xmpp-websocket-anonymous'
url: string
@ -16,7 +20,7 @@ interface LiveChatJSONLDAnonymousBOSHLink {
jid: string
}
type LiveChatJSONLDLink = LiveChatJSONLDAnonymousBOSHLink | LiveChatJSONLDAnonymousWebsocketLink
type LiveChatJSONLDLink = LiveChatJSONLDS2SLink | LiveChatJSONLDAnonymousBOSHLink | LiveChatJSONLDAnonymousWebsocketLink
interface LiveChatJSONLDInfos {
type: 'xmpp'