From dd9f4b4dd4feafd58d32b15b2b907e4ecea6a7a9 Mon Sep 17 00:00:00 2001 From: Noah Petherbridge Date: Tue, 28 Mar 2023 18:34:50 -0700 Subject: [PATCH] Bugfixes with user status --- pkg/handlers.go | 22 ++++++++++++++++++++++ web/templates/chat.html | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/pkg/handlers.go b/pkg/handlers.go index e141ef0..0cc0483 100644 --- a/pkg/handlers.go +++ b/pkg/handlers.go @@ -238,6 +238,28 @@ func (s *Server) OnMe(sub *Subscriber, msg Message) { log.Debug("User %s turns on their video feed", sub.Username) } + // Hidden status: for operators only, + fake a join/exit chat message. + if sub.JWTClaims != nil && sub.JWTClaims.IsAdmin { + if sub.ChatStatus != "hidden" && msg.ChatStatus == "hidden" { + // Going hidden - fake leave message + s.Broadcast(Message{ + Action: ActionPresence, + Username: sub.Username, + Message: "has exited the room!", + }) + } else if sub.ChatStatus == "hidden" && msg.ChatStatus != "hidden" { + // Leaving hidden - fake join message + s.Broadcast(Message{ + Action: ActionPresence, + Username: sub.Username, + Message: "has joined the room!", + }) + } + } else if msg.ChatStatus == "hidden" { + // normal users can not set this status + msg.ChatStatus = "away" + } + sub.VideoActive = msg.VideoActive sub.VideoNSFW = msg.NSFW sub.ChatStatus = msg.ChatStatus diff --git a/web/templates/chat.html b/web/templates/chat.html index 13cc6d0..bf794c3 100644 --- a/web/templates/chat.html +++ b/web/templates/chat.html @@ -697,7 +697,7 @@ - +