Chat status updates

This commit is contained in:
Noah 2023-03-28 18:09:13 -07:00
parent 3560e63096
commit e69449124e
4 changed files with 10 additions and 5 deletions

View File

@ -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

View File

@ -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
}

View File

@ -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

View File

@ -697,6 +697,7 @@
<option value="online">☀️ Active</option>
<option value="away">🕒 Away</option>
<option value="idle" v-show="status==='idle'">🕒 Idle</option>
<option value="hidden" v-show="jwt.claims != undefined && jwt.claims.op">🕵️ Hidden</option>
</select>
</div>
</div>