06c9ece058
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>
42 lines
848 B
Ruby
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
|