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 type { Video } from '@peertube/peertube-types'
import type { RegisterClientOptions } from '@peertube/peertube-types/client'
import { videoHasWebchat } from 'shared/lib/video'
import { videoHasWebchat, videoHasRemoteWebchat } from 'shared/lib/video'
import { logger } from './videowatch/logger'
import { closeSVG, openBlankChatSVG, openChatSVG, shareChatUrlSVG } from './videowatch/buttons'
import { displayButton, displayButtonOptions } from './videowatch/button'
@ -247,19 +247,21 @@ function register (registerOptions: RegisterClientOptions): void {
logger.log('No chat for anonymous users')
return
}
if (!videoHasWebchat(s, video)) {
if (!videoHasWebchat(s, video) && !videoHasRemoteWebchat(s, video)) {
logger.log('This video has no webchat')
return
}
let showShareUrlButton: boolean = false
const chatShareUrl = settings['chat-share-url'] ?? ''
if (chatShareUrl === 'everyone') {
showShareUrlButton = true
} else if (chatShareUrl === 'owner') {
showShareUrlButton = guessIsMine(registerOptions, video)
} else if (chatShareUrl === 'owner+moderators') {
showShareUrlButton = guessIsMine(registerOptions, video) || guessIamIModerator(registerOptions)
if (video.isLocal) { // No need for shareButton on remote chats.
const chatShareUrl = settings['chat-share-url'] ?? ''
if (chatShareUrl === 'everyone') {
showShareUrlButton = true
} else if (chatShareUrl === 'owner') {
showShareUrlButton = guessIsMine(registerOptions, video)
} else if (chatShareUrl === 'owner+moderators') {
showShareUrlButton = guessIsMine(registerOptions, video) || guessIamIModerator(registerOptions)
}
}
insertChatDom(container as HTMLElement, video, !!settings['chat-open-blank'], showShareUrlButton).then(() => {