From 034cc6d0bde85fcd7f21c9f08d6acbe334ab84d6 Mon Sep 17 00:00:00 2001 From: Doug Lauder Date: Mon, 13 Feb 2023 08:48:42 -0500 Subject: [PATCH] avoid divide by zero when hubs not created before first websocket msg (#22315) --- app/platform/web_hub.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/platform/web_hub.go b/app/platform/web_hub.go index 9e62da4264..8b54ce76c7 100644 --- a/app/platform/web_hub.go +++ b/app/platform/web_hub.go @@ -121,6 +121,10 @@ func (ps *PlatformService) HubStop() { // GetHubForUserId returns the hub for a given user id. func (ps *PlatformService) GetHubForUserId(userID string) *Hub { + if len(ps.hubs) == 0 { + return nil + } + // TODO: check if caching the userID -> hub mapping // is worth the memory tradeoff. // https://mattermost.atlassian.net/browse/MM-26629.