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>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
6bad385164
Коммит
50eaec6695
@@ -2904,7 +2904,7 @@ func (a *App) SearchChannelsUserNotIn(teamID string, userID string, term string)
|
||||
func (a *App) MarkChannelsAsViewed(channelIDs []string, userID string, currentSessionId string, collapsedThreadsSupported bool) (map[string]int64, *model.AppError) {
|
||||
// I start looking for channels with notifications before I mark it as read, to clear the push notifications if needed
|
||||
channelsToClearPushNotifications := []string{}
|
||||
if *a.Config().EmailSettings.SendPushNotifications {
|
||||
if a.canSendPushNotifications() {
|
||||
for _, channelID := range channelIDs {
|
||||
channel, errCh := a.Srv().Store.Channel().Get(channelID, true)
|
||||
if errCh != nil {
|
||||
|
||||
@@ -17,12 +17,8 @@ const (
|
||||
|
||||
// NotifySessionsExpired is called periodically from the job server to notify any mobile sessions that have expired.
|
||||
func (a *App) NotifySessionsExpired() error {
|
||||
if *a.Config().EmailSettings.SendPushNotifications {
|
||||
pushServer := *a.Config().EmailSettings.PushNotificationServer
|
||||
if license := a.ch.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.")
|
||||
return nil
|
||||
}
|
||||
if !a.canSendPushNotifications() {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Get all mobile sessions that expired within the last hour.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -578,6 +578,10 @@ func (a *App) BuildPushNotificationMessage(contentsConfig string, post *model.Po
|
||||
}
|
||||
|
||||
func (a *App) SendTestPushNotification(deviceID string) string {
|
||||
if !a.canSendPushNotifications() {
|
||||
return "false"
|
||||
}
|
||||
|
||||
msg := &model.PushNotification{
|
||||
Version: "2",
|
||||
Type: model.PushTypeTest,
|
||||
|
||||
Ссылка в новой задаче
Block a user