Skip to content

Filter invalid notifications from emails being sent#15002

Merged
greenwoodt merged 18 commits intodevelopfrom
fix/disgest-notifications
Dec 2, 2025
Merged

Filter invalid notifications from emails being sent#15002
greenwoodt merged 18 commits intodevelopfrom
fix/disgest-notifications

Conversation

@alecslupu
Copy link
Copy Markdown
Contributor

@alecslupu alecslupu commented Jul 18, 2025

🎩 What? Why?

This PR fixes some bugs with the notifications:

  • If a resource is being moderated, the resource is still being sent in the digest notification
  • If a comment is being moderated, is still being sent in digest
  • If a resource is being deleted by the owner, then that resource is still being visible in the digest notification
  • If a resource is being deleted by the owner, then that resource is still being visible in notifications panel
  • If a resource belongs to an unpublished component, is being sent

📌 Related Issues

Link your PR to an issue

Testing

The main idea is to create a simulation on what is happening when an user that follows a space receives a notification email for a resources that has been moderated? That resource should not be sent via email.

  1. Go to your rails console and type in Decidim::Notification.delete_all
  2. In same console type: Decidim::User.first.update_attribute(:digest_sent_at, nil)
  3. On a browser login as admin
  4. On another browser login as user
  5. Make sure both users are following the space
  6. Create a resource ( ex proposal )
  7. Add 3 comments as user
  8. As user delete a comment
  9. As admin moderate a comment
  10. One leave untouched
  11. Console type: Decidim::Notification.update_all(created_at: 30.hours.ago) - you should have 3 records
  12. In terminal type bin/rails decidim:mailers:notifications_digest_daily
  13. After a while, see your digest contain all 3 notifications
  14. Apply patch
  15. In console type: Decidim::User.first.update_attribute(:digest_sent_at, nil)
  16. In terminal type bin/rails decidim:mailers:notifications_digest_daily
  17. After a while, see your digest contain 1 notification

Scenario 2:

  1. On a browser login as admin
  2. On another browser login as user
  3. Make sure both users are following the space
  4. Create a resource ( ex proposal )
  5. Add 3 comments as user
  6. As admin click "hide from menu"
  7. then on the proposal component again click "unpublish"
  8. As user the user notifications page
  9. See the notification generated in the unpublished space is still visible
  10. Apply patch
  11. See the notification disappeared

📷 Screenshots

Please add screenshots of the changes you are proposing
Description

♥️ Thank you!

@github-actions github-actions bot added module: core type: fix PRs that implement a fix for a bug labels Jul 18, 2025
github-actions[bot]
github-actions bot previously approved these changes Jul 18, 2025
github-actions[bot]
github-actions bot previously approved these changes Jul 18, 2025
@alecslupu alecslupu requested a review from a team July 18, 2025 22:20
@alecslupu alecslupu added release: v0.30 Issues or PRs that need to be tackled for v0.30 release: v0.31 Issues or PRs that need to be tackled for v0.31 labels Nov 26, 2025
Copy link
Copy Markdown
Member

@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.

Ran your steps and my user "John Doe" at "hi@example.org" in develop and still didn't get an email that it was moderated.

image

Only the admin and space admins on the assembly I followed got emails

image

Copy link
Copy Markdown
Member

@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.

On the branch we can still see with moderated content visible (comments) in the digest:
Image

However the component is actually moderated, so its a partial fix but while some content is visible, the code within the notifications_digest_mailer is written to obstructe that information from the followers perspective, so this will need another look @alecslupu.

@alecslupu alecslupu assigned alecslupu and unassigned greenwoodt Nov 28, 2025
github-actions[bot]
github-actions bot previously approved these changes Nov 29, 2025
github-actions[bot]
github-actions bot previously approved these changes Nov 29, 2025
github-actions[bot]
github-actions bot previously approved these changes Nov 29, 2025
github-actions[bot]
github-actions bot previously approved these changes Nov 29, 2025
github-actions[bot]
github-actions bot previously approved these changes Nov 29, 2025
github-actions[bot]
github-actions bot previously approved these changes Nov 29, 2025
Copy link
Copy Markdown
Member

@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.

The 1 deleted + 1 moderated commit is properly obfuscated from the digest:
Image

Second scenario worked fantastic. User doesn't see the component notifications when unpublished:
Image

Approving with codecov errors in the CI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module: accountability module: comments module: core release: v0.30 Issues or PRs that need to be tackled for v0.30 release: v0.31 Issues or PRs that need to be tackled for v0.31 type: fix PRs that implement a fix for a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Empty notifications digest email

2 participants