Respect send push proxy notification configuration on test notifications (#20063)

* Respect send push proxy notification configuration on test notifications

* Unify notifications check

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
Daniel Espino García
2022-05-10 12:37:47 +02:00
коммит произвёл GitHub
родитель 6bad385164
Коммит 50eaec6695
4 изменённых файлов: 22 добавлений и 19 удалений

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

@@ -22,6 +22,20 @@ import (
"github.com/mattermost/mattermost-server/v6/store"
)
func (a *App) canSendPushNotifications() bool {
if !*a.Config().EmailSettings.SendPushNotifications {
return false
}
pushServer := *a.Config().EmailSettings.PushNotificationServer
if license := a.Srv().License(); pushServer == model.MHPNS && (license == nil || !*license.Features.MHPNS) {
mlog.Warn("Push notifications have been disabled. Update your license or go to System Console > Environment > Push Notification Server to use a different server")
return false
}
return true
}
func (a *App) SendNotifications(post *model.Post, team *model.Team, channel *model.Channel, sender *model.User, parentPostList *model.PostList, setOnline bool) ([]string, error) {
// Do not send notifications in archived channels
if channel.DeleteAt > 0 {
@@ -401,18 +415,7 @@ func (a *App) SendNotifications(post *model.Post, team *model.Team, channel *mod
}
}
sendPushNotifications := false
if *a.Config().EmailSettings.SendPushNotifications {
pushServer := *a.Config().EmailSettings.PushNotificationServer
if license := a.Srv().License(); pushServer == model.MHPNS && (license == nil || !*license.Features.MHPNS) {
mlog.Warn("Push notifications are disabled. Go to System Console > Notifications > Mobile Push to enable them.")
sendPushNotifications = false
} else {
sendPushNotifications = true
}
}
if sendPushNotifications {
if a.canSendPushNotifications() {
for _, id := range mentionedUsersList {
if profileMap[id] == nil || notificationsForCRT.Push.Contains(id) {
continue