Add base_url to native push notification payload

Include the server's base URL so native apps can identify which Fizzy
instance (SaaS or self-hosted) a notification originated from.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Rosa Gutierrez
2026-02-25 13:57:25 +01:00
parent 6fb24118ea
commit 13268ef668
2 changed files with 13 additions and 0 deletions
@@ -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
@@ -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