From 7de54f063cb260dfcae6c21563df3a044e2160b1 Mon Sep 17 00:00:00 2001 From: enahum Date: Thu, 2 Mar 2017 18:38:38 -0300 Subject: Fix push notifications where channel is set to all activity (#5594) * Fix push notifications where channel is set to all activity * feedback review * moved push notification logic to DoesStatusAllowPushNotification * Have every option handled in ShouldSendPushNotification * unit tests --- app/status.go | 18 ------------------ 1 file changed, 18 deletions(-) (limited to 'app/status.go') diff --git a/app/status.go b/app/status.go index bef17165f..51e7d1ed8 100644 --- a/app/status.go +++ b/app/status.go @@ -235,21 +235,3 @@ func GetStatus(userId string) (*model.Status, *model.AppError) { func IsUserAway(lastActivityAt int64) bool { return model.GetMillis()-lastActivityAt >= *utils.Cfg.TeamSettings.UserStatusAwayTimeout*1000 } - -func DoesStatusAllowPushNotification(user *model.User, status *model.Status, channelId string) bool { - props := user.NotifyProps - - if props["push"] == "none" { - return false - } - - if pushStatus, ok := props["push_status"]; (pushStatus == model.STATUS_ONLINE || !ok) && (status.ActiveChannel != channelId || model.GetMillis()-status.LastActivityAt > model.STATUS_CHANNEL_TIMEOUT) { - return true - } else if pushStatus == model.STATUS_AWAY && (status.Status == model.STATUS_AWAY || status.Status == model.STATUS_OFFLINE) { - return true - } else if pushStatus == model.STATUS_OFFLINE && status.Status == model.STATUS_OFFLINE { - return true - } - - return false -} -- cgit v1.2.3-1-g7c22