KEMBAR78
Hide comments when parent resource is hidden by andra-panaite · Pull Request #13554 · decidim/decidim · GitHub
Skip to content

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

Scenario 1:
  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. Wait a while (~ 5 mins)
  6. The comments should no longer be displayed in the user profile/general search section.
Scenario 2:
  1. Log in as an admin user.
  2. Find a proposal.
  3. Make a comment thread on that proposal
  4. Report the starting comment and hide it.
  5. Wait a while (~ 5 mins)
  6. All the comments of that thread should also dissapear from search

📷 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
Member

@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 

@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 Issues or PRs that need to be tackled for 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 Issues or PRs that need to be tackled for v0.29 labels Nov 15, 2024
Co-authored-by: Andrés Pereira de Lucena <andreslucena@users.noreply.github.com>
github-actions[bot]
github-actions bot previously approved these changes Feb 21, 2025
…mples.rb

Co-authored-by: Andrés Pereira de Lucena <andreslucena@users.noreply.github.com>
github-actions[bot]
github-actions bot previously approved these changes Feb 21, 2025
github-actions[bot]
github-actions bot previously approved these changes Feb 21, 2025
@alecslupu
Copy link
Member

@andreslucena this is ready to a second round

Copy link
Member

@andreslucena andreslucena left a comment

Choose a reason for hiding this comment

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

👍🏽

@andreslucena andreslucena dismissed alecslupu’s stale review February 24, 2025 13:56

Alex took over this PR so he'll not review it

@andreslucena andreslucena merged commit eadc2f2 into decidim:develop Feb 24, 2025
112 checks passed
@alecslupu alecslupu deleted the fix/hiding-comments-of-hidden-proposal branch February 24, 2025 14:02
@alecslupu alecslupu added the release: v0.30 Issues or PRs that need to be tackled for v0.30 label Feb 24, 2025
andreslucena added a commit that referenced this pull request Mar 3, 2025
* Hide comments when parent resource is hidden

* Resolved comments

Signed-off-by: andra-panaite <andra.panaite@tremend.com>

* Run linter

* Run linter

* Added hide_replies method to handle reported comments with replies

* Run linter

* Resolved comments

* Fixed tests

* Fix User case

* Update decidim-core/lib/decidim/moderation_tools.rb

Co-authored-by: Andrés Pereira de Lucena <andreslucena@users.noreply.github.com>

* Update decidim-core/lib/decidim/core/test/shared_examples/reports_examples.rb

Co-authored-by: Andrés Pereira de Lucena <andreslucena@users.noreply.github.com>

* Apply review recommendations

* Add release notes

---------

Signed-off-by: andra-panaite <andra.panaite@tremend.com>
Co-authored-by: Alexandru Emil Lupu <contact@alecslupu.ro>
Co-authored-by: Andrés Pereira de Lucena <andreslucena@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module: admin module: ai module: comments module: core module: meetings module: proposals release: v0.28 Issues or PRs that need to be tackled for v0.28 release: v0.29 Issues or PRs that need to be tackled for v0.29 release: v0.30 Issues or PRs that need to be tackled for v0.30 type: fix PRs that implement a fix for a bug

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

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

4 participants