From a6fa2b72d1375e554cc6f2e5ca2fd4884a8509f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Espino?= Date: Mon, 1 Oct 2018 10:22:31 +0200 Subject: Migrate to idiomatic error handling app/notification*.go (#9487) --- app/notification_email.go | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'app/notification_email.go') diff --git a/app/notification_email.go b/app/notification_email.go index cfc1bb4fd..117988e2a 100644 --- a/app/notification_email.go +++ b/app/notification_email.go @@ -22,27 +22,28 @@ func (a *App) sendNotificationEmail(notification *postNotification, user *model. post := notification.post if channel.IsGroupOrDirect() { - if result := <-a.Srv.Store.Team().GetTeamsByUserId(user.Id); result.Err != nil { + result := <-a.Srv.Store.Team().GetTeamsByUserId(user.Id) + if result.Err != nil { return result.Err - } else { - // if the recipient isn't in the current user's team, just pick one - teams := result.Data.([]*model.Team) - found := false - - for i := range teams { - if teams[i].Id == team.Id { - found = true - break - } - } + } + + // if the recipient isn't in the current user's team, just pick one + teams := result.Data.([]*model.Team) + found := false - if !found && len(teams) > 0 { - team = teams[0] - } else { - // in case the user hasn't joined any teams we send them to the select_team page - team = &model.Team{Name: "select_team", DisplayName: a.Config().TeamSettings.SiteName} + for i := range teams { + if teams[i].Id == team.Id { + found = true + break } } + + if !found && len(teams) > 0 { + team = teams[0] + } else { + // in case the user hasn't joined any teams we send them to the select_team page + team = &model.Team{Name: "select_team", DisplayName: a.Config().TeamSettings.SiteName} + } } if *a.Config().EmailSettings.EnableEmailBatching { @@ -357,7 +358,6 @@ func (a *App) GetMessageForNotification(post *model.Post, translateFunc i18n.Tra if onlyImages { return translateFunc("api.post.get_message_for_notification.images_sent", len(filenames), props) - } else { - return translateFunc("api.post.get_message_for_notification.files_sent", len(filenames), props) } + return translateFunc("api.post.get_message_for_notification.files_sent", len(filenames), props) } -- cgit v1.2.3-1-g7c22