Skip to content

Mail notifications digest#8833

Merged
andreslucena merged 44 commits intodevelopfrom
feature/mail-notifications-digest
May 17, 2022
Merged

Mail notifications digest#8833
andreslucena merged 44 commits intodevelopfrom
feature/mail-notifications-digest

Conversation

@quinHD
Copy link
Copy Markdown
Contributor

@quinHD quinHD commented Feb 16, 2022

🎩 What? Why?

This PR adds the mail digest feature for user notifications. It makes available a rake task to send the email only to the selected users. It can be invoked from a cron job.

📌 Related Issues

#8486

Testing

Describe the best way to test or validate your PR.

#####Acceptance criteria#####

  • Given that I'm an implementer,
    When I go to https://docs.decidim.org/en/install/#_scheduled_tasks I have instructions on how to set this feature for new apps. (docs/modules/install/pages/index.adoc)
  • Given that I'm an implementer,
    When I go to the CHANGELOG I have instructions on how to set this feature for existing apps.
  • Given that I'm a participant,
    When I go to "My account" -> "Notifications settings"
    Then I see a new section "How often do you want to receive the notifications emails?" with the options "None", "Real time", "Daily" and "Weekly"
  • Given that I'm a participant that had selected "I want to receive an email every time I receive a notification",
    When I go to "My account" -> "Notifications settings"
    Then I have selected the "Real time" option in "How often do you want to receive the notifications emails?"
  • Given that I'm a new registered participant,
    When I go to "My account" -> "Notifications settings"
    Then I have selected the "Daily" option by default in "How often do you want to receive the notifications emails?"
  • Given that I'm a participant,
    When I have selected the "None" option in "How often do you want to receive the notifications emails?"
    Then I don't receive any notifications emails.
  • Given that I'm a participant,
    When I have selected the "Real time" option in "How often do you want to receive the notifications emails?"
    Then I receive emails every time I have a notification.
  • Given that I'm a participant,
    When I have selected the "Daily" option in "How often do you want to receive the notifications emails?"
    Then I receive one email with my notifications from yesterday.
  • Given that I'm a participant,
    When I have selected the "Weekly" option in "How often do you want to receive the notifications emails?"
    Then I receive one email with my notifications from the last week.

📋 Checklist

🚨 Please review the guidelines for contributing to this repository.

  • CONSIDER adding a unit test if your PR resolves an issue.
  • ✔️ DO check open PR's to avoid duplicates.
  • ✔️ DO keep pull requests small so they can be easily reviewed.
  • ✔️ DO build locally before pushing.
  • ✔️ DO make sure tests pass.
  • ✔️ DO make sure any new changes are documented in docs/.
  • ✔️ DO add and modify seeds if necessary.
  • ✔️ DO add CHANGELOG upgrade notes if required.
  • ✔️ DO add to GraphQL API if there are new public fields.
  • ✔️ DO add link to MetaDecidim if it's a new feature.
  • AVOID breaking the continuous integration build.
  • AVOID making significant changes to the overall architecture.

📷 Screenshots

Please add screenshots of the changes you're proposing
Description

♥️ Thank you!

@quinHD quinHD self-assigned this Feb 16, 2022
@quinHD quinHD force-pushed the feature/mail-notifications-digest branch from e931bcb to f5c047b Compare February 16, 2022 23:28
@quinHD quinHD linked an issue Feb 16, 2022 that may be closed by this pull request
9 tasks
@quinHD quinHD marked this pull request as ready for review February 17, 2022 01:35
@quinHD quinHD changed the title Add mail notifications digest Mail notifications digest Feb 17, 2022
@quinHD
Copy link
Copy Markdown
Contributor Author

quinHD commented Feb 17, 2022

@andreslucena. Where should be the documentation relative to this feature? in a page in this repo, or in docs repo?

@andreslucena andreslucena added project: PWA Barcelona City Council contract module: core type: feature labels Feb 18, 2022
@andreslucena
Copy link
Copy Markdown
Member

@andreslucena. Where should be the documentation relative to this feature? in a page in this repo, or in docs repo?

It depends in which kind of docs did you have in mind. If it's for developers/implementers, then it should be here (docs/ directory). If it's for admins/users it should be in https://github.com/decidim/documentation

@andreslucena
Copy link
Copy Markdown
Member

andreslucena commented Feb 18, 2022

Uops sorry for closing this, wrong click 😅

@alecslupu
Copy link
Copy Markdown
Contributor

@quinHD Can you normalize the locales?

Copy link
Copy Markdown
Contributor

@ferblape ferblape left a comment

Choose a reason for hiding this comment

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

Just a few details to review, plus I miss a test about the use of the digest_sent_at attribute, for example checking that this field value blocks emails already been sent.

@ferblape
Copy link
Copy Markdown
Contributor

Also, take care with the I18n, it needs to be normalized

@ferblape
Copy link
Copy Markdown
Contributor

ready to review @decidim/product

ferblape
ferblape previously approved these changes Mar 24, 2022
@andreslucena
Copy link
Copy Markdown
Member

I have reviewed it locally, and there are some things that we need to change regarding the flow and feature.

Please merge with develop and also configure it in decidim.populate.tools/letter_opener so we can check the UI with @carolromero

I found confusing having to check the "Send notifications by email" and also the "How often do you want to receive the notifications digest email?" at the same time to receive notifications. The whole point of this feature is that I already receive too many emails from notifications. I think this could be easily fixed by:

  • changing the question from "How often do you want to receive the notifications digest email?" to "How often do you want to receive the notifications emails?"
  • adding a new radio for "Real time" (as you've in the mockup)
  • reordering the options so it makes sense (now its "Daily", "None" and "Weekly"), it should be "None", "Real time", "Daily" and "Weekly"
  • dropping the "Send notifications by email" section in this page (and column in the DB), migrating the users that have selected that to "Real time"

Regarding where to add the docs for implementers, I think it's easier to discover on the section for scheduled tasks in the install guide (docs/modules/install/pages/index.adoc) and also a few lines in the CHANGELOG so it's easier to find by existing implementers.

So the ACs have changed reflecting better this so it's easier to keep track of it.

@andreslucena
Copy link
Copy Markdown
Member

This is how it'd look like the final result of the notifications settings:

image

@andreslucena andreslucena added the release: v0.27 Issues or PRs that need to be tackled for v0.27 label Apr 21, 2022
@ahukkanen
Copy link
Copy Markdown
Contributor

@quinHD @ferblape Could you kindly rebase (or merge with develop)? There are some conflicts. 🙏

Copy link
Copy Markdown
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.

There are some merge conflicts, and I have a couple suggestions. Can you give it a look please? Thanks!

ferblape and others added 4 commits May 5, 2022 05:26
Co-authored-by: Andrés Pereira de Lucena <andreslucena@users.noreply.github.com>
Co-authored-by: Andrés Pereira de Lucena <andreslucena@users.noreply.github.com>
@ferblape
Copy link
Copy Markdown
Contributor

ferblape commented May 5, 2022

@andreslucena feedback added and conflicts fixed

Copy link
Copy Markdown
Contributor

@ahukkanen ahukkanen left a comment

Choose a reason for hiding this comment

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

I really like how elegantly this is implemented, great work! It was a pleasure to read through.

I just noticed one unnecessary addition as far as I understood, so could you take a look at that?

Also, can you solve the merge conflicts and fix the Rubocop issue after merging with develop please? 🙏

Also, I noticed a potential bug but I'll post it as a separate message below.

@ahukkanen
Copy link
Copy Markdown
Contributor

I'm not sure if I have something misconfigured but when I tried the "real time" notifications locally, it was generating duplicate records for me as shown in the video below:

decidim-dupicate-notification.mp4

Because of this, it was also sending duplicate emails to me.

I tried this locally and I was running the jobs through the delayed_job adapter using the rake jobs:work process.

I tried the same also on develop and it was working correctly on develop, i.e. generating only a single notification.

Could you take a look at this?

@ferblape
Copy link
Copy Markdown
Contributor

Thanks for your time and your review @ahukkanen

I haven't been able to reproduce the double notification issue. I've tried both without async_adapter, and with a job adapter configured, and in both cases only one notification was generated

Also, I reviewed the logs and everything look ok: just a single job enqueued, job which internally generates a couple more of jobs, one for the notification and the other for the email.

Could you pase your development log when you have time to debug what could fail?

@ahukkanen
Copy link
Copy Markdown
Contributor

I haven't been able to reproduce the double notification issue. I've tried both without async_adapter, and with a job adapter configured, and in both cases only one notification was generated

Also, I reviewed the logs and everything look ok: just a single job enqueued, job which internally generates a couple more of jobs, one for the notification and the other for the email.

Could you pase your development log when you have time to debug what could fail?

Thanks @ferblape !

It must have been some misconfiguration on my end because today I just regenerated the development_app from scratch and now only one job is enqueued and I cannot replicate the bug.

So functionality-wise it all good now! I'll take another look at the changes and it should be good to go on my part.

@ahukkanen ahukkanen requested a review from andreslucena May 16, 2022 15:42
@andreslucena andreslucena merged commit b6a7d56 into develop May 17, 2022
@andreslucena andreslucena deleted the feature/mail-notifications-digest branch May 17, 2022 08:19
andreslucena added a commit that referenced this pull request May 19, 2022
* Add notifications digest email

* Fix specs & lints

* Fix erb lint

* Remove unused frequency radio button

* Refactor radio buttons in notifications settings

* Fix i18n spec

* Add notifications frequency to form

* Add notifications digest documentation

* Add none to notification frequency

* Remove relations in mailer arguments

* Refactor mail notifications digest sending method

* Fix error in migration

* Fix lint

* Add spec for notifications digest sending decider

* Rearrange notification settings

* Remove email_on_notification attribute

* Fix locales order

* Fix lint

* Fix i18n specs

* Fix meetings specs

* Update docs with mailer

* Add to changelog

* Refactor migration

* Clarification on the documentation

* Convert to local variable

* Remove comment

* Add field to serializer

* Test on form

* Simplify migrations

* Fix default value for new users

* Add more details to changelog

* Typo

* Fix spec

* Update CHANGELOG.md

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

* Update docs/modules/install/pages/index.adoc

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

* Ruby linter

* Remove docs from installation page

* Use symbols

Co-authored-by: Antti Hukkanen <antti.hukkanen@mainiotech.fi>

* Fix offenses

* Fix i18n

* Fix offenses

Co-authored-by: Fernando Blat <fernando@blat.es>
Co-authored-by: Andrés Pereira de Lucena <andreslucena@users.noreply.github.com>
Co-authored-by: Antti Hukkanen <antti.hukkanen@mainiotech.fi>
andreslucena added a commit that referenced this pull request May 19, 2022
* Add notifications digest email

* Fix specs & lints

* Fix erb lint

* Remove unused frequency radio button

* Refactor radio buttons in notifications settings

* Fix i18n spec

* Add notifications frequency to form

* Add notifications digest documentation

* Add none to notification frequency

* Remove relations in mailer arguments

* Refactor mail notifications digest sending method

* Fix error in migration

* Fix lint

* Add spec for notifications digest sending decider

* Rearrange notification settings

* Remove email_on_notification attribute

* Fix locales order

* Fix lint

* Fix i18n specs

* Fix meetings specs

* Update docs with mailer

* Add to changelog

* Refactor migration

* Clarification on the documentation

* Convert to local variable

* Remove comment

* Add field to serializer

* Test on form

* Simplify migrations

* Fix default value for new users

* Add more details to changelog

* Typo

* Fix spec

* Update CHANGELOG.md

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

* Update docs/modules/install/pages/index.adoc

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

* Ruby linter

* Remove docs from installation page

* Use symbols

Co-authored-by: Antti Hukkanen <antti.hukkanen@mainiotech.fi>

* Fix offenses

* Fix i18n

* Fix offenses

Co-authored-by: Fernando Blat <fernando@blat.es>
Co-authored-by: Andrés Pereira de Lucena <andreslucena@users.noreply.github.com>
Co-authored-by: Antti Hukkanen <antti.hukkanen@mainiotech.fi>
eliegaboriau pushed a commit to eliegaboriau/decidim that referenced this pull request Oct 25, 2022
* Add notifications digest email

* Fix specs & lints

* Fix erb lint

* Remove unused frequency radio button

* Refactor radio buttons in notifications settings

* Fix i18n spec

* Add notifications frequency to form

* Add notifications digest documentation

* Add none to notification frequency

* Remove relations in mailer arguments

* Refactor mail notifications digest sending method

* Fix error in migration

* Fix lint

* Add spec for notifications digest sending decider

* Rearrange notification settings

* Remove email_on_notification attribute

* Fix locales order

* Fix lint

* Fix i18n specs

* Fix meetings specs

* Update docs with mailer

* Add to changelog

* Refactor migration

* Clarification on the documentation

* Convert to local variable

* Remove comment

* Add field to serializer

* Test on form

* Simplify migrations

* Fix default value for new users

* Add more details to changelog

* Typo

* Fix spec

* Update CHANGELOG.md

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

* Update docs/modules/install/pages/index.adoc

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

* Ruby linter

* Remove docs from installation page

* Use symbols

Co-authored-by: Antti Hukkanen <antti.hukkanen@mainiotech.fi>

* Fix offenses

* Fix i18n

* Fix offenses

Co-authored-by: Fernando Blat <fernando@blat.es>
Co-authored-by: Andrés Pereira de Lucena <andreslucena@users.noreply.github.com>
Co-authored-by: Antti Hukkanen <antti.hukkanen@mainiotech.fi>
@alecslupu alecslupu added this to the 0.27.0 milestone Jul 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module: core project: PWA Barcelona City Council contract release: v0.27 Issues or PRs that need to be tackled for v0.27

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Notifications digest

5 participants