Move category and high_priority to payload classes

Use polymorphism instead of case statements in Native push target:
- DefaultPayload#category returns "default", #high_priority? returns false
- EventPayload#category returns "assignment"/"comment"/"card" based on action
- MentionPayload#category returns "mention", #high_priority? returns true

This simplifies the Native push target by delegating source-specific
logic to the appropriate payload classes.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Rosa Gutierrez
2026-01-22 13:19:18 +01:00
parent 9299300dbf
commit 4f19c42958
5 changed files with 43 additions and 50 deletions
@@ -23,6 +23,14 @@ class Notification::DefaultPayload
notifications_url
end
def category
"default"
end
def high_priority?
false
end
private
def card_url(card)
Rails.application.routes.url_helpers.card_url(card, **url_options)
+12
View File
@@ -36,6 +36,18 @@ class Notification::EventPayload < Notification::DefaultPayload
end
end
def category
case event.action
when "card_assigned" then "assignment"
when "comment_created" then "comment"
else "card"
end
end
def high_priority?
event.action.card_assigned?
end
private
def event
notification.source
@@ -13,6 +13,14 @@ class Notification::MentionPayload < Notification::DefaultPayload
card_url(card)
end
def category
"mention"
end
def high_priority?
true
end
private
def mention
notification.source