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:
John Livingston
2023-04-21 16:56:48 +02:00
parent b85a1dc90a
commit 5d323b2dfd
7 changed files with 236 additions and 79 deletions

View File

@ -1,6 +1,6 @@
import { parseConfigUUIDs } from './config'
interface SharedSettings {
interface VideoHasWebchatSettings {
'chat-per-live-video': boolean
'chat-all-lives': boolean
'chat-all-non-lives': boolean
@ -12,6 +12,7 @@ interface SharedVideoBase {
isLive: boolean
pluginData?: {
'livechat-active'?: boolean
'livechat-remote'?: boolean
}
}
@ -25,7 +26,13 @@ interface SharedVideoBackend extends SharedVideoBase {
type SharedVideo = SharedVideoBackend | SharedVideoFrontend
function videoHasWebchat (settings: SharedSettings, video: SharedVideo): boolean {
/**
* Indicate if the video has a local chat.
* @param settings plugin settings
* @param video the video
* @returns true if the video has a local chat
*/
function videoHasWebchat (settings: VideoHasWebchatSettings, video: SharedVideo): boolean {
// Never use webchat on remote videos.
if ('isLocal' in video) {
if (!video.isLocal) return false
@ -53,6 +60,29 @@ function videoHasWebchat (settings: SharedSettings, video: SharedVideo): boolean
return false
}
export {
videoHasWebchat
interface VideoHasRemoteWebchatSettings {
'federation-no-remote-chat': boolean
}
/**
* Indicates if the video has a remote chat.
* @param settings plugin settings
* @param video the video
* @returns true if the video has a remote chat
*/
function videoHasRemoteWebchat (settings: VideoHasRemoteWebchatSettings, video: SharedVideo): boolean {
if (settings['federation-no-remote-chat']) { return false }
if ('isLocal' in video) {
if (video.isLocal) return false
} else {
if (!video.remote) return false
}
if (!video.pluginData) { return false }
if (!video.pluginData['livechat-remote']) { return false }
return true
}
export {
videoHasWebchat,
videoHasRemoteWebchat
}