diff --git a/server/api.go b/server/api.go index 39641e726..3f1d7b27e 100644 --- a/server/api.go +++ b/server/api.go @@ -139,7 +139,7 @@ func (p *Plugin) handleGetAllChannels(w http.ResponseWriter, r *http.Request) { state, err := p.kvGetChannelState(channelID) if err != nil { p.LogError(err.Error()) - http.Error(w, appErr.Error(), http.StatusInternalServerError) + continue } enabled := state.Enabled diff --git a/server/utils.go b/server/utils.go index f3370eda4..21abc1931 100644 --- a/server/utils.go +++ b/server/utils.go @@ -113,7 +113,11 @@ func isMobilePostGA(r *http.Request) (mobile, postGA bool) { // https://mattermost.atlassian.net/browse/MM-48929 userAgent := r.Header.Get("User-Agent") fields := strings.Fields(userAgent) - clientAgent := fields[0] // safe to assume there's at least one + if len(fields) == 0 { + return false, false + } + + clientAgent := fields[0] isMobile := strings.HasPrefix(clientAgent, "rnbeta") || strings.HasPrefix(clientAgent, "Mattermost") if !isMobile { return false, false diff --git a/server/utils_test.go b/server/utils_test.go index bd54afbe1..c2d71178d 100644 --- a/server/utils_test.go +++ b/server/utils_test.go @@ -47,6 +47,13 @@ func Test_isMobilePostGA(t *testing.T) { wantMobile: true, wantPostGA: true, }, + { + name: "no user agent", + userAgent: "", + params: "", + wantMobile: false, + wantPostGA: false, + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) {