diff --git a/app/models/notification/default_payload.rb b/app/models/notification/default_payload.rb index 65ca068e2..98f104856 100644 --- a/app/models/notification/default_payload.rb +++ b/app/models/notification/default_payload.rb @@ -31,6 +31,10 @@ class Notification::DefaultPayload false end + def base_url + Rails.application.routes.url_helpers.root_url(**url_options.except(:script_name)).chomp("/") + end + def avatar_url Rails.application.routes.url_helpers.user_avatar_url(notification.creator, **url_options) end diff --git a/saas/test/models/notification/push_target/native_test.rb b/saas/test/models/notification/push_target/native_test.rb index fe06f83f7..c6e1c9d4f 100644 --- a/saas/test/models/notification/push_target/native_test.rb +++ b/saas/test/models/notification/push_target/native_test.rb @@ -194,6 +194,15 @@ class Notification::PushTarget::NativeTest < ActiveSupport::TestCase assert_equal @notification.creator.name, native.data[:creator_name] end + test "native notification includes base_url without account slug" do + @identity.devices.create!(token: "test123", platform: "apple", name: "Test iPhone") + + push = Notification::PushTarget::Native.new(@notification) + native = push.send(:native_notification) + + assert_equal "http://example.com", native.data[:base_url] + end + private def assert_native_push_delivery(count: 1, &block) assert_enqueued_jobs count, only: ApplicationPushNotificationJob do