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
Этот коммит содержится в:
enahum
2017-03-02 18:38:38 -03:00
коммит произвёл GitHub
родитель 47114a18e3
Коммит 7de54f063c
3 изменённых файлов: 348 добавлений и 32 удалений

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

@@ -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
}