Take control over your live stream video by running it yourself. Streaming + chat out of the box.
HTML activitypubbroadcastingchatdecentralizedfederationfediversegolanghacktoberfesthlslivelivestreamowncastrtmpself-hostedstreaming-videovideo
Expose connected client ID to moderator client info api
Gabe Kangasc59fab2e8bcc
diff --git a/controllers/moderation/moderation.go b/controllers/moderation/moderation.goindex d799e4608e..c59323b1db 100644--- a/controllers/moderation/moderation.go+++ b/controllers/moderation/moderation.go@@ -16,6 +16,7 @@ import (// GetUserDetails returns the details of a chat user for moderators.func GetUserDetails(w http.ResponseWriter, r *http.Request) {type connectedClient struct {+ Id uint `json:"id"`MessageCount int `json:"messageCount"`UserAgent string `json:"userAgent"`ConnectedAt time.Time `json:"connectedAt"`@@ -42,6 +43,7 @@ func GetUserDetails(w http.ResponseWriter, r *http.Request) {clients := make([]connectedClient, len(c))for i, c := range c {client := connectedClient{+ Id: c.Id,MessageCount: c.MessageCount,UserAgent: c.UserAgent,ConnectedAt: c.ConnectedAt,diff --git a/core/chat/chatclient.go b/core/chat/chatclient.goindex 3e02e71589..771d7dbd1d 100644--- a/core/chat/chatclient.go+++ b/core/chat/chatclient.go@@ -20,7 +20,7 @@ import (// Client represents a single chat client.type Client struct {mu sync.RWMutex- id uint+ Id uint `json:"-"`accessToken stringconn *websocket.ConnUser *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.Idclose(c.send)c.send = nil}diff --git a/core/chat/events.go b/core/chat/events.goindex 892d264217..081a1532ce 100644--- a/core/chat/events.go+++ b/core/chat/events.go@@ -90,7 +90,7 @@ func (s *Server) userNameChanged(eventData chatClientEvent) {// Send chat user name changed webhookreceivedEvent.User = savedUser- receivedEvent.ClientID = eventData.client.id+ receivedEvent.ClientID = eventData.client.Idwebhooks.SendChatEventUsernameChanged(receivedEvent)// Resend the client's user so their username is in sync.@@ -128,7 +128,7 @@ func (s *Server) userMessageSent(eventData chatClientEvent) {}event.SetDefaults()- event.ClientID = eventData.client.id+ event.ClientID = eventData.client.Id// Ignore empty messagesif event.Empty() {diff --git a/core/chat/server.go b/core/chat/server.goindex d8692a8ca0..7d49757aa8 100644--- a/core/chat/server.go+++ b/core/chat/server.go@@ -99,14 +99,14 @@ func (s *Server) Addclient(conn *websocket.Conn, user *user.User, accessToken sts.mu.Lock(){- client.id = s.seq- s.clients[client.id] = client+ client.Id = s.seq+ s.clients[client.Id] = clients.seq++_lastSeenCache[user.ID] = time.Now()}s.mu.Unlock()- log.Traceln("Adding client", client.id, "total count:", len(s.clients))+ log.Traceln("Adding client", client.Id, "total count:", len(s.clients))go client.writePump()go client.readPump()@@ -132,7 +132,7 @@ func (s *Server) sendUserJoinedMessage(c *Client) {userJoinedEvent := events.UserJoinedEvent{}userJoinedEvent.SetDefaults()userJoinedEvent.User = c.User- userJoinedEvent.ClientID = c.id+ userJoinedEvent.ClientID = c.Idif err := s.Broadcast(userJoinedEvent.GetBroadcastPayload()); err != nil {log.Errorln("error adding client to chat server", err)@@ -148,9 +148,9 @@ func (s *Server) ClientClosed(c *Client) {defer s.mu.Unlock()c.close()- if _, ok := s.clients[c.id]; ok {- log.Debugln("Deleting", c.id)- delete(s.clients, c.id)+ if _, ok := s.clients[c.Id]; ok {+ log.Debugln("Deleting", c.Id)+ delete(s.clients, c.Id)}}