diff --git a/src/api/app/components/notification_notifiable_link_component.rb b/src/api/app/components/notification_notifiable_link_component.rb index aae06072f30..e9779ecbdaa 100644 --- a/src/api/app/components/notification_notifiable_link_component.rb +++ b/src/api/app/components/notification_notifiable_link_component.rb @@ -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 !user_event.is_deleted? || current_user_is_admin + 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 when 'Event::ReportForRequest' bs_request = @notification.notifiable.reportable Rails.application.routes.url_helpers.request_show_path(bs_request.number, notification_id: @notification.id) @@ -206,17 +206,5 @@ def path_to_commentables_on_reports(event_payload:, notification_id:) anchor: 'comments-list') end end - - # rubocop:disable ViewComponent/AvoidGlobalState - def user_event - User.find_by_login(@notification.event_payload['user_login']) - end - # rubocop:enable ViewComponent/AvoidGlobalState - - # rubocop:disable ViewComponent/AvoidGlobalState - def current_user_is_admin - User.admin_session? - end - # rubocop:enable ViewComponent/AvoidGlobalState end # rubocop:enable Metrics/ClassLength diff --git a/src/api/app/helpers/webui/user_helper.rb b/src/api/app/helpers/webui/user_helper.rb index 863d3cf3019..8dcdd475b1b 100644 --- a/src/api/app/helpers/webui/user_helper.rb +++ b/src/api/app/helpers/webui/user_helper.rb @@ -101,6 +101,14 @@ 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 + private def project_package_message