Skip to content

Commit

Permalink
Let notification extracts the event_user internally
Browse files Browse the repository at this point in the history
  • Loading branch information
ncounter committed Feb 23, 2024
1 parent 4834edf commit 018b898
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def notifiable_link_path
when 'Event::ReportForProject', 'Event::ReportForPackage'
@notification.event_type.constantize.notification_link_path(@notification)
when 'Event::ReportForUser'
Rails.application.routes.url_helpers.user_path(@notification.event_payload['user_login'], notification_id: @notification.id) if !helpers.user_by_login(@notification.event_payload['user_login']).is_deleted? || helpers.current_user_is_admin
Rails.application.routes.url_helpers.user_path(@notification.event_payload['user_login'], notification_id: @notification.id) if !@notification.event_user.is_deleted? || helpers.current_user_is_admin
when 'Event::ReportForRequest'
bs_request = @notification.notifiable.reportable
Rails.application.routes.url_helpers.request_show_path(bs_request.number, notification_id: @notification.id)
Expand Down
4 changes: 0 additions & 4 deletions src/api/app/helpers/webui/user_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,6 @@ def filter_message(params)
"#{result}."
end

def user_by_login(user_login)
User.find_by_login(user_login)
end

def current_user_is_admin
User.admin_session?
end
Expand Down
4 changes: 4 additions & 0 deletions src/api/app/models/notification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ def unread_date
last_seen_at || created_at
end

def event_user
User.find_by_login(event_payload['user_login']) if event_payload['user_login']
end

private

def track_notification_creation
Expand Down

0 comments on commit 018b898

Please sign in to comment.