summaryrefslogtreecommitdiffstats
path: root/app/web_hub.go
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2018-05-11 11:56:02 -0400
committerDerrick Anderson <derrick@andersonwebstudio.com>2018-05-11 11:56:02 -0400
commit91c998156336e34ab4b8979db77cc65c97a65782 (patch)
tree9ef0e50eb22f756da202c415945d162f66a11024 /app/web_hub.go
parent0dbaa2d032ae42cbf39945df12efb20fc572b559 (diff)
downloadchat-91c998156336e34ab4b8979db77cc65c97a65782.tar.gz
chat-91c998156336e34ab4b8979db77cc65c97a65782.tar.bz2
chat-91c998156336e34ab4b8979db77cc65c97a65782.zip
More potential panic fixes (#8776)
Diffstat (limited to 'app/web_hub.go')
-rw-r--r--app/web_hub.go15
1 files changed, 9 insertions, 6 deletions
diff --git a/app/web_hub.go b/app/web_hub.go
index f69645f50..2ce78b5ef 100644
--- a/app/web_hub.go
+++ b/app/web_hub.go
@@ -177,8 +177,9 @@ func (a *App) Publish(message *model.WebSocketEvent) {
func (a *App) PublishSkipClusterSend(message *model.WebSocketEvent) {
if message.Broadcast.UserId != "" {
- if len(a.Hubs) != 0 {
- a.GetHubForUserId(message.Broadcast.UserId).Broadcast(message)
+ hub := a.GetHubForUserId(message.Broadcast.UserId)
+ if hub != nil {
+ hub.Broadcast(message)
}
} else {
for _, hub := range a.Hubs {
@@ -299,8 +300,9 @@ func (a *App) InvalidateCacheForUserSkipClusterSend(userId string) {
a.Srv.Store.User().InvalidateProfilesInChannelCacheByUser(userId)
a.Srv.Store.User().InvalidatProfileCacheForUser(userId)
- if len(a.Hubs) != 0 {
- a.GetHubForUserId(userId).InvalidateUser(userId)
+ hub := a.GetHubForUserId(userId)
+ if hub != nil {
+ hub.InvalidateUser(userId)
}
}
@@ -322,8 +324,9 @@ func (a *App) InvalidateCacheForWebhookSkipClusterSend(webhookId string) {
}
func (a *App) InvalidateWebConnSessionCacheForUser(userId string) {
- if len(a.Hubs) != 0 {
- a.GetHubForUserId(userId).InvalidateUser(userId)
+ hub := a.GetHubForUserId(userId)
+ if hub != nil {
+ hub.InvalidateUser(userId)
}
}