diff options
author | Joram Wilander <jwawilander@gmail.com> | 2018-05-11 11:56:02 -0400 |
---|---|---|
committer | Derrick Anderson <derrick@andersonwebstudio.com> | 2018-05-11 11:56:02 -0400 |
commit | 91c998156336e34ab4b8979db77cc65c97a65782 (patch) | |
tree | 9ef0e50eb22f756da202c415945d162f66a11024 /app | |
parent | 0dbaa2d032ae42cbf39945df12efb20fc572b559 (diff) | |
download | chat-91c998156336e34ab4b8979db77cc65c97a65782.tar.gz chat-91c998156336e34ab4b8979db77cc65c97a65782.tar.bz2 chat-91c998156336e34ab4b8979db77cc65c97a65782.zip |
More potential panic fixes (#8776)
Diffstat (limited to 'app')
-rw-r--r-- | app/web_hub.go | 15 |
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) } } |