OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
hide restricted journals when user does not have access
Bruno Pagno0774b6983910
diff --git a/app/components/work_packages/activities_tab/journals/index_component.rb b/app/components/work_packages/activities_tab/journals/index_component.rbindex 35535014b0a..4ffa04627b2 100644--- a/app/components/work_packages/activities_tab/journals/index_component.rb+++ b/app/components/work_packages/activities_tab/journals/index_component.rb@@ -68,9 +68,12 @@ module WorkPackagesenddef fetch_journals+ can_see_restricted = User.current.allowed_in_work_package?(:view_comments_with_restricted_visibility, work_package)+API::V3::Activities::ActivityEagerLoadingWrapper.wrap(work_package.journals+ .where(can_see_restricted ? nil : { restricted: false }).includes(:user, :customizable_journals, :attachable_journals, :storable_journals, :notifications).reorder(version: journal_sorting).with_sequence_versiondiff --git a/app/models/activities/fetcher.rb b/app/models/activities/fetcher.rbindex 8eddb163198..7788302e830 100644--- a/app/models/activities/fetcher.rb+++ b/app/models/activities/fetcher.rb@@ -66,6 +66,7 @@ module Activitiesevents = events_from_providers(from, to, limit)eager_load_associations(events)+ filter_by_visibility(events)sort_by_most_recent_first(events)end@@ -114,6 +115,12 @@ module Activitiesendend+ def filter_by_visibility(events)+ events.reject! do |event|+ event.journal.restricted? && [email protected]_in_project?(:view_comments_with_restricted_visibility, event.project)+ end+ end+def projects_of_event_set(events)project_ids = events.filter_map(&:project_id).uniq@@ -130,10 +137,10 @@ module Activitiesjournal_ids = events.map(&:event_id)Journal- .includes(:data, :customizable_journals, :attachable_journals, :bcf_comment)- .find(journal_ids)- .then { |journals| ::API::V3::Activities::ActivityEagerLoadingWrapper.wrap(journals) }- .index_by(&:id)+ .includes(:data, :customizable_journals, :attachable_journals, :bcf_comment)+ .find(journal_ids)+ .then { |journals| ::API::V3::Activities::ActivityEagerLoadingWrapper.wrap(journals) }+ .index_by(&:id)enddef sort_by_most_recent_first(events)diff --git a/lib/api/v3/activities/activities_by_work_package_api.rb b/lib/api/v3/activities/activities_by_work_package_api.rbindex faddc9b8b75..08f245f169e 100644--- a/lib/api/v3/activities/activities_by_work_package_api.rb+++ b/lib/api/v3/activities/activities_by_work_package_api.rb@@ -35,11 +35,16 @@ module APIresource :activities doget doself_link = api_v3_paths.work_package_activities @work_package.id- journals = @work_package.journals.includes(:data,- :customizable_journals,- :attachable_journals,- :storable_journals,- :bcf_comment)++ can_see_restricted = User.current.allowed_in_work_package?(:view_comments_with_restricted_visibility, @work_package)+ journals = @work_package+ .journals+ .where(can_see_restricted ? nil : { restricted: false })+ .includes(:data,+ :customizable_journals,+ :attachable_journals,+ :storable_journals,+ :bcf_comment)Activities::ActivityCollectionRepresenter.new(journals,self_link:,