diff options
-rw-r--r-- | app/notification.go | 12 | ||||
-rw-r--r-- | app/notification_test.go | 2 |
2 files changed, 14 insertions, 0 deletions
diff --git a/app/notification.go b/app/notification.go index d69bb4e2e..d1f6225b3 100644 --- a/app/notification.go +++ b/app/notification.go @@ -179,6 +179,10 @@ func (a *App) SendNotifications(post *model.Post, team *model.Team, channel *mod if a.Config().EmailSettings.SendEmailNotifications { for _, id := range mentionedUsersList { + if profileMap[id] == nil { + continue + } + userAllowsEmails := profileMap[id].NotifyProps[model.EMAIL_NOTIFY_PROP] != "false" if channelEmail, ok := channelMemberNotifyPropsMap[id][model.EMAIL_NOTIFY_PROP]; ok { if channelEmail != model.CHANNEL_NOTIFY_DEFAULT { @@ -279,6 +283,10 @@ func (a *App) SendNotifications(post *model.Post, team *model.Team, channel *mod if sendPushNotifications { for _, id := range mentionedUsersList { + if profileMap[id] == nil { + continue + } + var status *model.Status var err *model.AppError if status, err = a.GetStatus(id); err != nil { @@ -291,6 +299,10 @@ func (a *App) SendNotifications(post *model.Post, team *model.Team, channel *mod } for _, id := range allActivityPushUserIds { + if profileMap[id] == nil { + continue + } + if _, ok := mentionedUserIds[id]; !ok { var status *model.Status var err *model.AppError diff --git a/app/notification_test.go b/app/notification_test.go index 8df19e2bf..24784940e 100644 --- a/app/notification_test.go +++ b/app/notification_test.go @@ -23,6 +23,8 @@ func TestSendNotifications(t *testing.T) { UserId: th.BasicUser.Id, ChannelId: th.BasicChannel.Id, Message: "@" + th.BasicUser2.Username, + Type: model.POST_ADD_TO_CHANNEL, + Props: map[string]interface{}{model.POST_PROPS_ADDED_USER_ID: "junk"}, }, true) if err != nil { |