Files
fizzy/app/models/notification/default_payload.rb
T
Rosa Gutierrez 06c9ece058 Move payload method to Notification and make accessors public
The notification now owns its payload via #payload method in Pushable,
allowing direct access like notification.payload.title. Push classes
simply use the notification's payload rather than building it themselves.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-25 19:31:13 +01:00

42 lines
848 B
Ruby

class Notification::DefaultPayload
attr_reader :notification
delegate :card, to: :notification
def initialize(notification)
@notification = notification
end
def to_h
{ title: title, body: body, url: url }
end
def title
"New notification"
end
def body
"You have a new notification"
end
def url
notifications_url
end
private
def card_url(card)
Rails.application.routes.url_helpers.card_url(card, **url_options)
end
def notifications_url
Rails.application.routes.url_helpers.notifications_url(**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