diff options
author | Jesús Espino <jespinog@gmail.com> | 2018-10-01 10:22:31 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-01 10:22:31 +0200 |
commit | a6fa2b72d1375e554cc6f2e5ca2fd4884a8509f4 (patch) | |
tree | 86fad78092116e88230b71bc56b47e9e8f125a07 /app/notification_email.go | |
parent | a8c01377bce777bf1940850e390e587c290e98e0 (diff) | |
download | chat-a6fa2b72d1375e554cc6f2e5ca2fd4884a8509f4.tar.gz chat-a6fa2b72d1375e554cc6f2e5ca2fd4884a8509f4.tar.bz2 chat-a6fa2b72d1375e554cc6f2e5ca2fd4884a8509f4.zip |
Migrate to idiomatic error handling app/notification*.go (#9487)
Diffstat (limited to 'app/notification_email.go')
-rw-r--r-- | app/notification_email.go | 38 |
1 files changed, 19 insertions, 19 deletions
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) } |