Chat Federation, connection to remote chat:
Front-end connect using BOSH or WS directly on the remote server. If use is logged-in, his nickname is use as default nickname.
This commit is contained in:
36
server/lib/federation/connection-infos.ts
Normal file
36
server/lib/federation/connection-infos.ts
Normal file
@ -0,0 +1,36 @@
|
||||
import type { LiveChatJSONLDAttribute } from './types'
|
||||
|
||||
interface AnonymousConnectionInfos {
|
||||
roomJID: string
|
||||
boshUri?: string
|
||||
wsUri?: string
|
||||
userJID: string
|
||||
}
|
||||
|
||||
function anonymousConnectionInfos (livechatInfos: LiveChatJSONLDAttribute | false): AnonymousConnectionInfos | null {
|
||||
if (!livechatInfos) { return null }
|
||||
if (!livechatInfos.links) { return null }
|
||||
if (livechatInfos.type !== 'xmpp') { return null }
|
||||
const r: AnonymousConnectionInfos = {
|
||||
roomJID: livechatInfos.jid,
|
||||
userJID: ''
|
||||
}
|
||||
for (const link of livechatInfos.links) {
|
||||
// Note: userJID is on both links. But should have the same value.
|
||||
if (link.type === 'xmpp-bosh-anonymous') {
|
||||
r.boshUri = link.url
|
||||
r.userJID = link.jid
|
||||
} else if (link.type === 'xmpp-websocket-anonymous') {
|
||||
r.wsUri = link.url
|
||||
r.userJID = link.jid
|
||||
}
|
||||
}
|
||||
if (r.userJID === '') {
|
||||
return null
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
export {
|
||||
anonymousConnectionInfos
|
||||
}
|
Reference in New Issue
Block a user