chat-share-url
This commit is contained in:
parent
ffb8be8b30
commit
c95dd1f713
1
client/@types/peertube.d.ts
vendored
1
client/@types/peertube.d.ts
vendored
@ -68,6 +68,7 @@ interface Video {
|
|||||||
originInstanceUrl: string
|
originInstanceUrl: string
|
||||||
uuid: string
|
uuid: string
|
||||||
channel: Channel
|
channel: Channel
|
||||||
|
byAccount: string
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Channel {
|
interface Channel {
|
||||||
|
@ -212,6 +212,7 @@ function register ({ registerHook, registerSettingsScript, peertubeHelpers }: Re
|
|||||||
case 'prosody-muc-expiration':
|
case 'prosody-muc-expiration':
|
||||||
case 'prosody-c2s':
|
case 'prosody-c2s':
|
||||||
case 'prosody-components':
|
case 'prosody-components':
|
||||||
|
case 'chat-share-url':
|
||||||
return options.formValues['chat-type'] !== ('builtin-prosody' as ChatType)
|
return options.formValues['chat-type'] !== ('builtin-prosody' as ChatType)
|
||||||
case 'prosody-c2s-port':
|
case 'prosody-c2s-port':
|
||||||
return !(
|
return !(
|
||||||
|
@ -11,6 +11,54 @@ interface VideoWatchLoadedHookOptions {
|
|||||||
playlist?: any
|
playlist?: any
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function guessIsMine (registerOptions: RegisterOptions, video: Video): boolean {
|
||||||
|
// Note: this is not safe, but it is not a problem:
|
||||||
|
// this function is used for non critical functions
|
||||||
|
try {
|
||||||
|
if (!video) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if (!video.isLocal) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if (!window.localStorage) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
const username = window.localStorage.getItem('username') ?? ''
|
||||||
|
if (!username) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if (username !== video.byAccount) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
} catch (err) {
|
||||||
|
logger.error(err as string)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function guessIamIModerator (_registerOptions: RegisterOptions): boolean {
|
||||||
|
// Note: this is not safe, but it is not a problem:
|
||||||
|
// this function is used for non critical functions
|
||||||
|
try {
|
||||||
|
if (!window.localStorage) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
const role = window.localStorage.getItem('role') ?? ''
|
||||||
|
if (!role) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if (role !== '0' && role !== '1') {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
} catch (err) {
|
||||||
|
logger.error(err as string)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function register (registerOptions: RegisterOptions): void {
|
function register (registerOptions: RegisterOptions): void {
|
||||||
const { registerHook, peertubeHelpers } = registerOptions
|
const { registerHook, peertubeHelpers } = registerOptions
|
||||||
let settings: any = {}
|
let settings: any = {}
|
||||||
@ -196,8 +244,18 @@ function register (registerOptions: RegisterOptions): void {
|
|||||||
|
|
||||||
let showShareUrlButton: boolean = false
|
let showShareUrlButton: boolean = false
|
||||||
if (settings['chat-type'] === 'builtin-prosody') {
|
if (settings['chat-type'] === 'builtin-prosody') {
|
||||||
// FIXME: showShareUrlButton should only be true for video owner and instance moderators.
|
// The share url functionality should be technically possible for other modes
|
||||||
showShareUrlButton = true
|
// than builtin-prosody. But it is too difficult to maintain.
|
||||||
|
// So I choose to enable it only for builtin-prosody.
|
||||||
|
|
||||||
|
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(() => {
|
insertChatDom(container as HTMLElement, video, !!settings['chat-open-blank'], showShareUrlButton).then(() => {
|
||||||
if (settings['chat-auto-display']) {
|
if (settings['chat-auto-display']) {
|
||||||
|
@ -130,8 +130,6 @@ async function shareChatUrl (registerOptions: RegisterOptions, settings: any, vi
|
|||||||
// Saving the form state, to restore each time the modal is opened.
|
// Saving the form state, to restore each time the modal is opened.
|
||||||
save(form)
|
save(form)
|
||||||
|
|
||||||
// TODO: check when the feature should be available
|
|
||||||
|
|
||||||
const uriOptions: UriOptions = {
|
const uriOptions: UriOptions = {
|
||||||
ignoreAutoColors: form.autoColors ? !form.autoColors.checked : true,
|
ignoreAutoColors: form.autoColors ? !form.autoColors.checked : true,
|
||||||
permanent: true
|
permanent: true
|
||||||
|
@ -67,6 +67,15 @@ Here is the documentation: [common settings](./common.md).
|
|||||||
|
|
||||||
### Prosody advanced settings
|
### Prosody advanced settings
|
||||||
|
|
||||||
|
#### Show the «share chat link» button
|
||||||
|
|
||||||
|
This feature enable a «share chat link» modal. With this modal, you can generate urls to join the chat.
|
||||||
|
The chat can be customized (readonly mode, use the current theme, ...).
|
||||||
|
|
||||||
|
You can for example generate a readonly url and use it in OBS to integrate the chat in your live stream!
|
||||||
|
|
||||||
|
This settings allows you to choose who can access this modal.
|
||||||
|
|
||||||
#### Peertube url for API calls
|
#### Peertube url for API calls
|
||||||
|
|
||||||
In some rare cases, Prosody can't call Peertube's API from its public URI.
|
In some rare cases, Prosody can't call Peertube's API from its public URI.
|
||||||
@ -128,6 +137,18 @@ When you open the chat room in full screen, there will also be a menu with dedic
|
|||||||
|
|
||||||
## Advanced usages
|
## Advanced usages
|
||||||
|
|
||||||
### OBS Overlay using Matterbridge
|
### OBS Overlay
|
||||||
|
|
||||||
|
#### Using readonly chat url
|
||||||
|
|
||||||
|
You can use the «share chat link» feature (see above) to generate an url to your chat.
|
||||||
|
Check the «readonly» checkbox in the modal.
|
||||||
|
Then use this link as a «web browser source» in OBS.
|
||||||
|
|
||||||
|
Note: you can customize colors. This is undocumented yet, but you can try this:
|
||||||
|
in the modal, check «use curent theme colors», then you can try to manually change color values in the url.
|
||||||
|
You must use valid CSS color values, and they must be properly url encoded.
|
||||||
|
|
||||||
|
#### Using Matterbridge
|
||||||
|
|
||||||
Here is a tutorial to use Matterbridge with the plugin: <https://gitlab.com/refrac/obs-matterbridge-overlay/-/blob/master/documentation/peertube.md>
|
Here is a tutorial to use Matterbridge with the plugin: <https://gitlab.com/refrac/obs-matterbridge-overlay/-/blob/master/documentation/peertube.md>
|
||||||
|
@ -315,6 +315,20 @@ You can report the bug on the official
|
|||||||
descriptionHTML: '<h3>Prosody advanced settings</h3>'
|
descriptionHTML: '<h3>Prosody advanced settings</h3>'
|
||||||
})
|
})
|
||||||
|
|
||||||
|
registerSetting({
|
||||||
|
name: 'chat-share-url',
|
||||||
|
label: 'Show the «share chat link» button',
|
||||||
|
descriptionHTML: 'There will be a button for sharing a chat url (could be used to intregrated in OBS for example).',
|
||||||
|
private: false,
|
||||||
|
type: 'select',
|
||||||
|
default: 'owner',
|
||||||
|
options: [
|
||||||
|
{ label: 'Show for nobody', value: 'nobody' },
|
||||||
|
{ label: 'Show for everyone', value: 'everyone' },
|
||||||
|
{ label: 'Show for the video owner', value: 'owner' },
|
||||||
|
{ label: 'Show for the video owner and instance\'s moderators', value: 'owner+moderators' }
|
||||||
|
]
|
||||||
|
})
|
||||||
registerSetting({
|
registerSetting({
|
||||||
name: 'prosody-peertube-uri',
|
name: 'prosody-peertube-uri',
|
||||||
label: 'Peertube url for API calls',
|
label: 'Peertube url for API calls',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user