added media fixes, search, push updates, pwa, metrics. preparing release 1.0
This commit is contained in:
@@ -8,6 +8,8 @@ import (
|
||||
"sync"
|
||||
|
||||
"github.com/coder/websocket"
|
||||
|
||||
"messenger/internal/platform/metrics"
|
||||
)
|
||||
|
||||
// MembershipProvider resolves conversation membership and read state.
|
||||
@@ -145,6 +147,13 @@ func (h *Hub) PublishReactionChanged(conversationID, messageID, userID int64, em
|
||||
h.sendToConversation(conversationID, envelope{Type: evtType, Data: mustMarshal(evt)}, 0)
|
||||
}
|
||||
|
||||
// IsOnline reports whether a user has at least one active WebSocket connection.
|
||||
func (h *Hub) IsOnline(userID int64) bool {
|
||||
h.mu.Lock()
|
||||
defer h.mu.Unlock()
|
||||
return len(h.conns[userID]) > 0
|
||||
}
|
||||
|
||||
func (h *Hub) register(c *client, conversationIDs []int64) {
|
||||
h.mu.Lock()
|
||||
defer h.mu.Unlock()
|
||||
@@ -158,6 +167,7 @@ func (h *Hub) register(c *client, conversationIDs []int64) {
|
||||
}
|
||||
h.subs[cid][c.userID] = struct{}{}
|
||||
}
|
||||
metrics.RecordWS(1)
|
||||
}
|
||||
|
||||
func (h *Hub) unregister(c *client, conversationIDs []int64) {
|
||||
@@ -177,6 +187,7 @@ func (h *Hub) unregister(c *client, conversationIDs []int64) {
|
||||
}
|
||||
}
|
||||
}
|
||||
metrics.RecordWS(-1)
|
||||
close(c.done)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user