Fix #97 #54: Settings to hide the chat for anonymous users

This commit is contained in:
John Livingston
2022-04-11 18:12:12 +02:00
parent d24ef987a0
commit 01a052d380
6 changed files with 59 additions and 14 deletions

View File

@ -13,6 +13,10 @@ interface VideoWatchLoadedHookOptions {
playlist?: any
}
function isAnonymousUser (registerOptions: RegisterClientOptions): boolean {
return !registerOptions.peertubeHelpers.isLoggedIn()
}
function guessIsMine (registerOptions: RegisterClientOptions, video: Video): boolean {
// Note: this is not safe, but it is not a problem:
// this function is used for non critical functions
@ -239,6 +243,10 @@ function register (registerOptions: RegisterClientOptions): void {
settings = s
logger.log('Checking if this video should have a chat...')
if (settings['chat-no-anonymous'] === true && isAnonymousUser(registerOptions)) {
logger.log('No chat for anonymous users')
return
}
if (!videoHasWebchat(s, video)) {
logger.log('This video has no webchat')
return