Migrate to idiomatic error handling in app/security_update_check.go (#9691)

Этот коммит содержится в:
Hanzei
2018-10-18 17:44:06 +02:00
коммит произвёл Christopher Speller
родитель 5d6d450299
Коммит d77e3a4c25

Просмотреть файл

@@ -86,29 +86,29 @@ func (a *App) DoSecurityUpdateCheck() {
for _, bulletin := range bulletins { for _, bulletin := range bulletins {
if bulletin.AppliesToVersion == model.CurrentVersion { if bulletin.AppliesToVersion == model.CurrentVersion {
if props["SecurityBulletin_"+bulletin.Id] == "" { 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.") mlog.Error("Failed to get system admins for security update information from Mattermost.")
return return
} else { }
users := results.Data.(map[string]*model.User) users := results.Data.(map[string]*model.User)
resBody, err := http.Get(SECURITY_URL + "/bulletins/" + bulletin.Id) resBody, err := http.Get(SECURITY_URL + "/bulletins/" + bulletin.Id)
if err != nil { if err != nil {
mlog.Error("Failed to get security bulletin details") mlog.Error("Failed to get security bulletin details")
return return
} }
body, err := ioutil.ReadAll(resBody.Body) body, err := ioutil.ReadAll(resBody.Body)
res.Body.Close() res.Body.Close()
if err != nil || resBody.StatusCode != 200 { if err != nil || resBody.StatusCode != 200 {
mlog.Error("Failed to read security bulletin details") mlog.Error("Failed to read security bulletin details")
return return
} }
for _, user := range users { for _, user := range users {
mlog.Info(fmt.Sprintf("Sending security bulletin for %v to %v", bulletin.Id, user.Email)) 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)) a.SendMail(user.Email, utils.T("mattermost.bulletin.subject"), string(body))
}
} }
bulletinSeen := &model.System{Name: "SecurityBulletin_" + bulletin.Id, Value: bulletin.Id} bulletinSeen := &model.System{Name: "SecurityBulletin_" + bulletin.Id, Value: bulletin.Id}