Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide comments when parent resource is hidden #13554

Open
wants to merge 13 commits into
base: develop
Choose a base branch
from

Conversation

andra-panaite
Copy link
Contributor

@andra-panaite andra-panaite commented Oct 16, 2024

🎩 What? Why?

Added a new method HideChildeResourcesJob to search and hide all comments related to the hidden parent resource and also to hide replies when a parent comment is reported and hidden.
Added a new task decidim:upgrade:clean:hidden_resources to hide all the comments from previously hidden resources.

📌 Related Issues

Testing

  1. Log in as an admin user.
  2. Create a proposal.
  3. Leave some comments -> The comments are now displayed in the user profile/general search section.
  4. Report the proposal and hide it.
  5. The comments should no longer be displayed in the user profile/general search section.

📷 Screenshots

Please add screenshots of the changes you are proposing
Description

♥️ Thank you!

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pull request does not contain a valid label. Please add one of the following labels: ['type: feature', 'type: change', 'type: fix', 'type: removal', 'target: developer-experience', 'type: internal']

@alecslupu alecslupu added the type: fix PRs that implement a fix for a bug label Oct 16, 2024
github-actions[bot]
github-actions bot previously approved these changes Oct 16, 2024
Copy link
Contributor

@alecslupu alecslupu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As of # we also need to patch decidim-ai/lib/decidim/ai/spam_detection/resource/base.rb and change the way resource_hidden? is being implemented.
A suggestion would be:

          def resource_hidden?(resource)
            resource.class.included_modules.include?(Decidim::Reportable) && resource.hidden? && !spam_reasons.include?(resource.reports&.last.&reason)
          end

          def spam_reasons 
             Decidim::Report::REASONS.excluding("parent_hidden")
          end 

decidim-core/lib/decidim/moderation_tools.rb Outdated Show resolved Hide resolved
decidim-core/lib/decidim/moderation_tools.rb Outdated Show resolved Hide resolved
decidim-core/lib/tasks/upgrade/clean_hidden_resources.rake Outdated Show resolved Hide resolved
@alecslupu alecslupu self-assigned this Oct 16, 2024
github-actions[bot]
github-actions bot previously approved these changes Oct 17, 2024
github-actions[bot]
github-actions bot previously approved these changes Oct 18, 2024
github-actions[bot]
github-actions bot previously approved these changes Oct 18, 2024
github-actions[bot]
github-actions bot previously approved these changes Nov 5, 2024
github-actions[bot]
github-actions bot previously approved these changes Nov 5, 2024
@alecslupu alecslupu added release: v0.28 Issues or PRs that need to be tackled for v0.28 release: v0.29 labels Nov 15, 2024
@greenwoodt greenwoodt added backport Pull Requests that are a backport for a fixed bug module: comments module: proposals and removed release: v0.28 Issues or PRs that need to be tackled for v0.28 release: v0.29 labels Nov 15, 2024
@greenwoodt greenwoodt added release: v0.28 Issues or PRs that need to be tackled for v0.28 release: v0.27 Issues or PRs that need to be tackled for v0.27 and removed backport Pull Requests that are a backport for a fixed bug labels Nov 15, 2024
decidim-core/lib/decidim/moderation_tools.rb Outdated Show resolved Hide resolved
decidim-core/lib/decidim/moderation_tools.rb Outdated Show resolved Hide resolved
decidim-ai/lib/decidim/ai/spam_detection/resource/base.rb Outdated Show resolved Hide resolved
github-actions[bot]
github-actions bot previously approved these changes Nov 21, 2024
github-actions[bot]
github-actions bot previously approved these changes Nov 21, 2024
@alecslupu alecslupu assigned greenwoodt and unassigned alecslupu Dec 6, 2024
@alecslupu alecslupu requested a review from greenwoodt December 6, 2024 14:58
Copy link
Contributor

@greenwoodt greenwoodt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tired it out locally with Sidekiq running and the comments seem to still exist in the general search even when the Proposal is hidden...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module: comments module: proposals release: v0.27 Issues or PRs that need to be tackled for v0.27 release: v0.28 Issues or PRs that need to be tackled for v0.28 type: fix PRs that implement a fix for a bug
Projects
Status: 🏗 In progress
Development

Successfully merging this pull request may close these issues.

When hiding a proposal, comments should also be hidden but they aren't
3 participants