Send multiple notifications by email#5875
Send multiple notifications by email#5875armandfardeau wants to merge 67 commits intodecidim:developfrom armandfardeau:feature/send-multiple-notifications-by-email
Conversation
|
I've labeled the task as WIP, please, feel free to remove the label when the PR is ready :D |
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. @carolromero & @andreslucena feel free to chime in. |
|
Hi @armandfardeau cc @virgile-dev |
|
Hi @andreslucena we are definitely planning to work on this, we will do a peer with @Quentinchampenois. Please note that in the future version of this feature, multiple notifications per email will be the default setting and single-mode will be an option. |
|
Do you have an estimated time on when you'll find time for working on this again? Long-lived PRs are a maintenance nightmare (too many conflicts). |
Hi @andreslucena, Sorry for the answer delay, I am planning on working on this PR this week |
|
Hi, I worked on this PR this week. I have added a priority feature to decide if a notification must be sent directly or can be delayed and send with other notifications. Now, the question is, what is the priority to set for each notification ? By default, a notification with undefined priority will have a low priority. What's left to finish this PR is to come up with a list for high priority notification (ex: forgot password, you don't want that to go in a batch). I'll be making a list of these in this comment, don't hesitate to comment back if you feel we missed some important ones. High priority notifications ideas:
|
|
Good work @Quentinchampenois! @carolromero and @andreslucena, what do you think about this list of high priority notifications (not going in a batch):
Moreover, for Initiatives, I think there is a difference between mailer and events. How do you think we should deal with it? |
|
I would say that all admin and platform notifications should have high priority, on the other side notifications coming from participant interactions could have low priority. |
|
Also, note that not all interactions that you mention would generate a notification. For example a "user forgot password" event simply generates an email, not a notification. I would leave this non notification emails out of scope. |
|
Hi everyone, So we think that the digest should contain the notifications related to the activity I follow. As a participant I probably want to receive a direct notification if someone mentions me or interacts with some content that I have created. |
Yes that's the way we are doing it. |
* increase batch notifications tasks specs * add priority to EmailNotification and Notification generators job * allow notification generator to receive priority * add priority to events * add priority to job notification generator for recipient * add priority to email notification generator * add priority to notification mailer * add priority to email notification generator job * update high_priority method in event publisher job * add rule rubocop * revert added specs in batch email notification
* Notification generators job harmonization * light clean batch_email_notifications * ensure notif are not sent for destroyed account * light clean of specs * fix redundant config in specs
|
Hello @tramuntanal It was a long trip but it's finished. You can find the test instructions in the issue description. |
* fix css loading in emails * update resource_text to safe_resource_text for event received template * Revert "update resource_text to safe_resource_text for event received template" This reverts commit a5ddf52. * change notifications format in email batch notifications * update translation and tests * light refactor emails scss
|
Hi @armandfardeau I was going to review this but I get system errors when trying to access any participatory space. Would you please take a look at it? 🙏 Thanks |
|
@carolromero Hi, thank you for doing this acceptance test. Could you reproduce the error so that we can intercept it? |
|
@armandfardeau sure!
|
Odd, I can't see anything on the monitoring. |
|
@armandfardeau I can see errors visiting this page: https://dcd-batch-notifications.osp.dev/processes/nemo-aspernatur |
Thanks, we caught it via Sentry. I can't see the same errors as you. |
|
Hey @armandfardeau @Quentinchampenois |
|
Also we were discussing with @Quentinchampenois yesterday about the max notification that can fit in the email by default. |
Thanks for the feedback! |
|
@armandfardeau is there any updates on this? I see some conflicts, check them out please! 😄 |
|
Hello everyone, we talked about this P.R. at OSP and we made the decision to close it because we can't work on it properly. We may reopen another one in the future. |


🎩 What? Why?
Batch email notifications
Batch email notifications are a way to send several email notifications at the same time.
This is useful for grouping notifications and not overloading your users emails.
Notifications are sent in groups, sorted from the most recent notifications.
Notifications that have not been sent after a certain time are not sent at all. This means that your users have already received plenty of them and will already have to visit the platform.
Deleting a notification cancels the future associated email.
This is based on 3 parameters:
batch_email_notifications_enabled: Enable batch email notifications and disable single email notification (default to false)
batch_email_notifications_expired: period of time after which a notification is considered to have expired (default to 1 week)
batch_email_notifications_max_length: Number of notifications to send in the same email (default to 5)
How to setup?
App setup
In
config/initialize/decidim.rbSet to desired value
Server setup
Batch email notification required to execute a rake task ("rake decidim:batch_email_notifications:send") at regular intervals.
Cron setup
Use
crontab -eand enter the following lines:You could find the documentation about cron on cron man page
Heroku scheduler
You can find information on how to setup heroku scheduler on heroku documentation
Sidekiq scheduler
In
config/sidekiq.ymlMany thanks to @Quentinchampenois for his help and co-authorship
📋 Subtasks
📷 Screenshots (optional)
Demo
https://dcd-batch-notifications.osp.dev/
Sidekiq available connected as a system user at https://dcd-batch-notifications.osp.dev/sidekiq/
Letter opener available https://dcd-batch-notifications.osp.dev/letter_opener/
To test: