Add more specific messages to event push payload body

This commit is contained in:
Jirka Hutárek
2026-02-27 18:17:56 +01:00
parent b93752dbb5
commit 9678bdbd24
2 changed files with 78 additions and 0 deletions
+18
View File
@@ -24,6 +24,16 @@ class Notification::EventPayload < Notification::DefaultPayload
"Reopened by #{event.creator.name}"
when "card_triaged"
"Moved to #{column_name} by #{event.creator.name}"
when "card_sent_back_to_triage"
"Moved back to Maybe? by #{event.creator.name}"
when "card_board_changed"
"Moved to #{new_board_name} by #{event.creator.name}"
when "card_title_changed"
"Renamed to #{new_title} by #{event.creator.name}"
when "card_postponed"
"Moved to Not Now by #{event.creator.name}"
when "card_auto_postponed"
"Moved to Not Now due to inactivity"
else
event.creator.name
end
@@ -63,6 +73,14 @@ class Notification::EventPayload < Notification::DefaultPayload
event.particulars.dig("particulars", "column")
end
def new_board_name
event.particulars.dig("particulars", "new_board")
end
def new_title
event.particulars.dig("particulars", "new_title")
end
def card_url_with_comment_anchor(comment)
Rails.application.routes.url_helpers.card_url(
comment.card,
@@ -77,6 +77,66 @@ class Notification::PushTarget::WebTest < ActiveSupport::TestCase
Notification::PushTarget::Web.new(@notification).process
end
test "payload for sent back to triage includes Maybe?" do
event = events(:logo_published)
event.update!(action: "card_sent_back_to_triage")
@notification.update!(source: event)
@web_push_pool.expects(:queue).once.with do |payload, _|
payload[:body] == "Moved back to Maybe? by #{event.creator.name}"
end
Notification::PushTarget::Web.new(@notification).process
end
test "payload for board change includes new board name" do
event = events(:logo_published)
event.update!(action: "card_board_changed", particulars: { "particulars" => { "old_board" => "Old Board", "new_board" => "New Board" } })
@notification.update!(source: event)
@web_push_pool.expects(:queue).once.with do |payload, _|
payload[:body] == "Moved to New Board by #{event.creator.name}"
end
Notification::PushTarget::Web.new(@notification).process
end
test "payload for title change includes new title" do
event = events(:logo_published)
event.update!(action: "card_title_changed", particulars: { "particulars" => { "old_title" => "Old Title", "new_title" => "New Title" } })
@notification.update!(source: event)
@web_push_pool.expects(:queue).once.with do |payload, _|
payload[:body] == "Renamed to New Title by #{event.creator.name}"
end
Notification::PushTarget::Web.new(@notification).process
end
test "payload for postponed includes Not Now" do
event = events(:logo_published)
event.update!(action: "card_postponed")
@notification.update!(source: event)
@web_push_pool.expects(:queue).once.with do |payload, _|
payload[:body] == "Moved to Not Now by #{event.creator.name}"
end
Notification::PushTarget::Web.new(@notification).process
end
test "payload for auto postponed includes inactivity message" do
event = events(:logo_published)
event.update!(action: "card_auto_postponed")
@notification.update!(source: event)
@web_push_pool.expects(:queue).once.with do |payload, _|
payload[:body] == "Moved to Not Now due to inactivity"
end
Notification::PushTarget::Web.new(@notification).process
end
test "payload for mention includes mentioner name" do
@web_push_pool.expects(:queue).once.with do |payload, _|
payload[:title].include?("mentioned you")