DEV: Include group_name in push notification payload for group mentions (#26081)

This commit is contained in:
Mark VanLandingham 2024-03-07 09:47:21 -06:00 committed by GitHub
parent 92d357f91a
commit 3b0b4e118c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 21 additions and 2 deletions

View File

@ -167,6 +167,7 @@ async function onNotification(data, siteSettings, user, appEvents) {
site_title: siteSettings.title,
topic: data.topic_title,
username: formatUsername(data.username),
group_name: data.group_name,
});
const notificationBody = data.excerpt;

View File

@ -13,7 +13,14 @@ class PostAlerter
post
end
def self.create_notification_alert(user:, post:, notification_type:, excerpt: nil, username: nil)
def self.create_notification_alert(
user:,
post:,
notification_type:,
excerpt: nil,
username: nil,
group_name: nil
)
return if user.suspended?
if post_url = post.url
@ -34,6 +41,7 @@ class PostAlerter
username: username || post.username,
post_url: post_url,
}
payload[:group_name] = group_name if group_name.present?
DiscourseEvent.trigger(:pre_notification_alert, user, payload)
@ -655,19 +663,28 @@ class PostAlerter
post: original_post,
notification_type: type,
username: original_username,
group_name: group&.name,
)
end
created.id ? created : nil
end
def create_notification_alert(user:, post:, notification_type:, excerpt: nil, username: nil)
def create_notification_alert(
user:,
post:,
notification_type:,
excerpt: nil,
username: nil,
group_name: nil
)
self.class.create_notification_alert(
user: user,
post: post,
notification_type: notification_type,
excerpt: excerpt,
username: username,
group_name: group_name,
)
end

View File

@ -58,6 +58,7 @@ class PushNotificationPusher
site_title: SiteSetting.title,
topic: payload[:topic_title],
username: payload[:username],
group_name: payload[:group_name],
)
end