From d77e3a4c2501ab9d0124b09f1b2d70554e686070 Mon Sep 17 00:00:00 2001 From: Hanzei <16541325+hanzei@users.noreply.github.com> Date: Thu, 18 Oct 2018 17:44:06 +0200 Subject: Migrate to idiomatic error handling in app/security_update_check.go (#9691) --- app/security_update_check.go | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/app/security_update_check.go b/app/security_update_check.go index f5b50c1c6..39c1a6ee9 100644 --- a/app/security_update_check.go +++ b/app/security_update_check.go @@ -86,29 +86,29 @@ func (a *App) DoSecurityUpdateCheck() { for _, bulletin := range bulletins { if bulletin.AppliesToVersion == model.CurrentVersion { if props["SecurityBulletin_"+bulletin.Id] == "" { - if results := <-a.Srv.Store.User().GetSystemAdminProfiles(); results.Err != nil { + results := <-a.Srv.Store.User().GetSystemAdminProfiles() + if results.Err != nil { mlog.Error("Failed to get system admins for security update information from Mattermost.") return - } else { - users := results.Data.(map[string]*model.User) - - resBody, err := http.Get(SECURITY_URL + "/bulletins/" + bulletin.Id) - if err != nil { - mlog.Error("Failed to get security bulletin details") - return - } - - body, err := ioutil.ReadAll(resBody.Body) - res.Body.Close() - if err != nil || resBody.StatusCode != 200 { - mlog.Error("Failed to read security bulletin details") - return - } - - for _, user := range users { - mlog.Info(fmt.Sprintf("Sending security bulletin for %v to %v", bulletin.Id, user.Email)) - a.SendMail(user.Email, utils.T("mattermost.bulletin.subject"), string(body)) - } + } + users := results.Data.(map[string]*model.User) + + resBody, err := http.Get(SECURITY_URL + "/bulletins/" + bulletin.Id) + if err != nil { + mlog.Error("Failed to get security bulletin details") + return + } + + body, err := ioutil.ReadAll(resBody.Body) + res.Body.Close() + if err != nil || resBody.StatusCode != 200 { + mlog.Error("Failed to read security bulletin details") + return + } + + for _, user := range users { + mlog.Info(fmt.Sprintf("Sending security bulletin for %v to %v", bulletin.Id, user.Email)) + a.SendMail(user.Email, utils.T("mattermost.bulletin.subject"), string(body)) } bulletinSeen := &model.System{Name: "SecurityBulletin_" + bulletin.Id, Value: bulletin.Id} -- cgit v1.2.3-1-g7c22