Skip to content

Commit

Permalink
Merge pull request #15378 from danidoni/implement-notifications-for-r…
Browse files Browse the repository at this point in the history
…eported-request-events

Implement notifications for reported request events
  • Loading branch information
danidoni committed Dec 19, 2023
2 parents 23d8831 + 1a68fd0 commit 524d1a2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ def description_text
# TODO: Remove `Event::CreateReport` after all existing records are migrated to the new STI classes
when 'Event::CreateReport', 'Event::ReportForProject', 'Event::ReportForPackage', 'Event::ReportForUser'
"'#{@notification.notifiable.user.login}' created a report for a #{@notification.event_payload['reportable_type'].downcase}. This is the reason:"
when 'Event::ReportForRequest'
"'#{@notification.notifiable.user.login}' created a report for a request. This is the reason:"
when 'Event::ReportForComment'
"'#{@notification.notifiable.user.login}' created a report for a comment from #{@notification.event_payload['commenter']}. This is the reason:"
when 'Event::ClearedDecision'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ def notifiable_link_text
end
when 'Event::ReportForProject', 'Event::ReportForPackage'
@notification.event_type.constantize.notification_link_text(@notification.event_payload)
when 'Event::ReportForRequest'
"Report for Request ##{@notification.notifiable.reportable.number}"
when 'Event::ClearedDecision'
# All reports should point to the same reportable. We will take care of that here:
# https://trello.com/c/xrjOZGa7/45-ensure-all-reports-of-a-decision-point-to-the-same-reportable
Expand Down Expand Up @@ -122,6 +124,9 @@ def notifiable_link_path
@notification.event_type.constantize.notification_link_path(@notification)
when 'Event::ReportForUser'
Rails.application.routes.url_helpers.user_path(@notification.event_payload['user_login'])
when 'Event::ReportForRequest'
bs_request = @notification.notifiable.reportable
Rails.application.routes.url_helpers.request_show_path(bs_request.number, notification_id: @notification.id)
when 'Event::ClearedDecision', 'Event::FavoredDecision'
reportable = @notification.notifiable.reports.first.reportable
link_for_reportables(reportable)
Expand Down
2 changes: 2 additions & 0 deletions src/api/app/services/notification_service/notifier.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class Notifier
'Event::ReportForPackage',
'Event::ReportForComment',
'Event::ReportForUser',
'Event::ReportForRequest',
'Event::ClearedDecision',
'Event::FavoredDecision',
'Event::WorkflowRunFail',
Expand All @@ -40,6 +41,7 @@ class Notifier
'Event::ReportForPackage',
'Event::ReportForComment',
'Event::ReportForUser',
'Event::ReportForRequest',
'Event::ClearedDecision',
'Event::FavoredDecision',
'Event::WorkflowRunFail'].freeze
Expand Down

0 comments on commit 524d1a2

Please sign in to comment.