diff --git a/app/models/notification_pusher.rb b/app/models/notification_pusher.rb index 1b50142bd..12b4965bd 100644 --- a/app/models/notification_pusher.rb +++ b/app/models/notification_pusher.rb @@ -45,7 +45,7 @@ class NotificationPusher base_payload = { title: card_notification_title(card), - path: card_path(card) + url: card_url(card) } case event.action @@ -53,7 +53,7 @@ class NotificationPusher base_payload.merge( title: "RE: #{base_payload[:title]}", body: comment_notification_body(event), - path: card_path_with_comment_anchor(event.eventable) + url: card_url_with_comment_anchor(event.eventable) ) when "card_assigned" base_payload.merge( @@ -85,7 +85,7 @@ class NotificationPusher { title: "#{mention.mentioner.first_name} mentioned you", body: format_excerpt(mention.source.mentionable_content, length: 200), - path: card_path(card) + url: card_url(card) } end @@ -93,7 +93,7 @@ class NotificationPusher { title: "New notification", body: "You have a new notification", - path: notifications_path(script_name: notification.account.slug) + url: notifications_url(**url_options) } end @@ -114,15 +114,22 @@ class NotificationPusher format_excerpt(event.eventable.body, length: 200) end - def card_path(card) - Rails.application.routes.url_helpers.card_path(card, script_name: notification.account.slug) + def card_url(card) + Rails.application.routes.url_helpers.card_url(card, **url_options) end - def card_path_with_comment_anchor(comment) - Rails.application.routes.url_helpers.card_path( + def card_url_with_comment_anchor(comment) + Rails.application.routes.url_helpers.card_url( comment.card, anchor: ActionView::RecordIdentifier.dom_id(comment), - script_name: notification.account.slug + **url_options ) end + + def url_options + base_options = Rails.application.routes.default_url_options.presence || + Rails.application.config.action_mailer.default_url_options || + {} + base_options.merge(script_name: notification.account.slug) + end end diff --git a/lib/web_push/notification.rb b/lib/web_push/notification.rb index 4c873fb48..c01caa953 100644 --- a/lib/web_push/notification.rb +++ b/lib/web_push/notification.rb @@ -1,6 +1,6 @@ class WebPush::Notification - def initialize(title:, body:, path:, badge:, endpoint:, endpoint_ip:, p256dh_key:, auth_key:) - @title, @body, @path, @badge = title, body, path, badge + def initialize(title:, body:, url:, badge:, endpoint:, endpoint_ip:, p256dh_key:, auth_key:) + @title, @body, @url, @badge = title, body, url, badge @endpoint, @endpoint_ip, @p256dh_key, @auth_key = endpoint, endpoint_ip, p256dh_key, auth_key end @@ -20,7 +20,7 @@ class WebPush::Notification end def encoded_message - JSON.generate title: @title, options: { body: @body, icon: icon_path, data: { path: @path, badge: @badge } } + JSON.generate title: @title, options: { body: @body, icon: icon_path, data: { url: @url, badge: @badge } } end def icon_path diff --git a/saas/app/models/notification_pusher/native.rb b/saas/app/models/notification_pusher/native.rb index cb03eec43..e5f83e40a 100644 --- a/saas/app/models/notification_pusher/native.rb +++ b/saas/app/models/notification_pusher/native.rb @@ -37,7 +37,7 @@ module NotificationPusher::Native .with_data( title: payload[:title], body: payload[:body], - path: payload[:path], + url: payload[:url], account_id: notification.account.external_account_id, avatar_url: creator_avatar_url, card_id: card&.id,