diff --git a/pkg/api.go b/pkg/api.go index abd354a..e48fd8b 100644 --- a/pkg/api.go +++ b/pkg/api.go @@ -36,7 +36,7 @@ func (s *Server) Statistics() http.HandlerFunc { // Count all users + collect unique usernames. var unique = map[string]struct{}{} for _, sub := range s.IterSubscribers() { - if sub.authenticated { + if sub.authenticated && sub.ChatStatus != "hidden" { result.UserCount++ if _, ok := unique[sub.Username]; ok { continue diff --git a/pkg/handlers.go b/pkg/handlers.go index 7dee948..e141ef0 100644 --- a/pkg/handlers.go +++ b/pkg/handlers.go @@ -145,7 +145,7 @@ func (s *Server) OnMessage(sub *Subscriber, msg Message) { } // If the sender already mutes the recipient, reply back with the error. - if sub.Mutes(rcpt.Username) { + if err == nil && sub.Mutes(rcpt.Username) { sub.ChatServer("You have muted %s and so your message has not been sent.", rcpt.Username) return } diff --git a/pkg/websocket.go b/pkg/websocket.go index c229e2c..c622e04 100644 --- a/pkg/websocket.go +++ b/pkg/websocket.go @@ -47,8 +47,8 @@ func (sub *Subscriber) ReadLoop(s *Server) { log.Error("ReadLoop error(%d=%s): %+v", sub.ID, sub.Username, err) s.DeleteSubscriber(sub) - // Notify if this user was auth'd - if sub.authenticated { + // Notify if this user was auth'd and not hidden + if sub.authenticated && sub.ChatStatus != "hidden" { s.Broadcast(Message{ Action: ActionPresence, Username: sub.Username, @@ -317,6 +317,10 @@ func (s *Server) SendWhoList() { var users = []WhoList{} for _, user := range subscribers { + if user.ChatStatus == "hidden" { + continue + } + who := WhoList{ Username: user.Username, Status: user.ChatStatus, @@ -330,7 +334,7 @@ func (s *Server) SendWhoList() { who.NSFW = false } - if sub.JWTClaims != nil { + if user.JWTClaims != nil { who.Operator = user.JWTClaims.IsAdmin who.Avatar = user.JWTClaims.Avatar who.ProfileURL = user.JWTClaims.ProfileURL diff --git a/web/templates/chat.html b/web/templates/chat.html index f7174cc..13cc6d0 100644 --- a/web/templates/chat.html +++ b/web/templates/chat.html @@ -697,6 +697,7 @@ +