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
Этот коммит содержится в:
@@ -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
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user