Expose connected client ID to moderator client info api

This commit is contained in:
Gabe Kangas
2022-12-13 19:17:32 -08:00
parent cdbb3b7a03
commit 3abc7a3ab8
4 changed files with 15 additions and 13 deletions
+4 -4
View File
@@ -20,7 +20,7 @@ import (
// Client represents a single chat client.
type Client struct {
mu sync.RWMutex
id uint
Id uint `json:"-"`
accessToken string
conn *websocket.Conn
User *user.User `json:"user"`
@@ -123,7 +123,7 @@ func (c *Client) readPump() {
// Guard against floods.
if !c.passesRateLimit() {
log.Warnln("Client", c.id, c.User.DisplayName, "has exceeded the messaging rate limiting thresholds and messages are being rejected temporarily.")
log.Warnln("Client", c.Id, c.User.DisplayName, "has exceeded the messaging rate limiting thresholds and messages are being rejected temporarily.")
c.startChatRejectionTimeout()
continue
@@ -186,14 +186,14 @@ func (c *Client) handleEvent(data []byte) {
}
func (c *Client) close() {
log.Traceln("client closed:", c.User.DisplayName, c.id, c.IPAddress)
log.Traceln("client closed:", c.User.DisplayName, c.Id, c.IPAddress)
c.mu.Lock()
defer c.mu.Unlock()
if c.send != nil {
_ = c.conn.Close()
c.server.unregister <- c.id
c.server.unregister <- c.Id
close(c.send)
c.send = nil
}