summaryrefslogtreecommitdiffstats
path: root/app/web_hub.go
diff options
context:
space:
mode:
Diffstat (limited to 'app/web_hub.go')
-rw-r--r--app/web_hub.go37
1 files changed, 25 insertions, 12 deletions
diff --git a/app/web_hub.go b/app/web_hub.go
index a50680806..9743d16aa 100644
--- a/app/web_hub.go
+++ b/app/web_hub.go
@@ -278,18 +278,20 @@ func (h *Hub) Start() {
}
case msg := <-h.broadcast:
- for _, webCon := range h.connections {
- if webCon.ShouldSendEvent(msg) {
- select {
- case webCon.Send <- msg:
- default:
- l4g.Error(fmt.Sprintf("webhub.broadcast: cannot send, closing websocket for userId=%v", webCon.UserId))
- close(webCon.Send)
- for i, webConCandidate := range h.connections {
- if webConCandidate == webCon {
- h.connections[i] = h.connections[len(h.connections)-1]
- h.connections = h.connections[:len(h.connections)-1]
- break
+ if OkToSendTypingMessage(msg) {
+ for _, webCon := range h.connections {
+ if webCon.ShouldSendEvent(msg) {
+ select {
+ case webCon.Send <- msg:
+ default:
+ l4g.Error(fmt.Sprintf("webhub.broadcast: cannot send, closing websocket for userId=%v", webCon.UserId))
+ close(webCon.Send)
+ for i, webConCandidate := range h.connections {
+ if webConCandidate == webCon {
+ h.connections[i] = h.connections[len(h.connections)-1]
+ h.connections = h.connections[:len(h.connections)-1]
+ break
+ }
}
}
}
@@ -328,3 +330,14 @@ func (h *Hub) Start() {
go doRecoverableStart()
}
+
+func OkToSendTypingMessage(msg *model.WebSocketEvent) bool {
+ // Only broadcast typing messages if less than 1K people in channel
+ if msg.Event == model.WEBSOCKET_EVENT_TYPING {
+ if Srv.Store.Channel().GetMemberCountFromCache(msg.Broadcast.ChannelId) > *utils.Cfg.TeamSettings.MaxNotificationsPerChannel {
+ return false
+ }
+ }
+
+ return true
+}