Send notification emails when notes have newly added mentions

What does this MR do and why?

Send notification emails when notes have newly added mentions.

I don't use to-dos; I have my own semi-elaborate system for keeping track of All The Things, and I use my email inbox as the way I find out about things I need to start keeping track of.

But! I found I was missing out on some things. Turns out people like to edit their comments to add mentions, and it turns out this is because that'll cause the item to appear in your to-dos. But not your email! Let's fix that!

This introduces the enhancement under a new feature flag, email_on_added_mentions: [FF] `email_on_added_mentions` -- notify users ... (#591869)

References

Fixes Notifying user when mentioned in an edited comment (#118779).

How to set up and validate locally

  1. Check the branch out, and enable the email_on_added_mentions FF. Feature.enable(:email_on_added_mentions) will work globally, or you can enable it for specific projects.
  2. Go clear out /rails/letter_opener (is it full of things?? mine was!).
  3. Choose a user that you're not logged in as to mention. (Pick someone from /admin/users.)
  4. Find or make a comment somewhere where it won't automatically notify that user; e.g. in a new issue in a project that belongs to your logged-in user.
  5. Refresh LetterOpener and confirm that no notification was sent.
  6. Edit that comment and add a @mention of the selected user.
  7. Refresh LetterOpener and confirm that a notification is sent to the selected user.

Note that, if you edit the comment to remove the mention, then edit it and add it back, a second email is sent! This behaviour is in line with to-dos: you'll also get two to-dos in this case.

Emails are also sent if you're already subscribed to the work item: this is intentional. The goal is to align email notifications and to-dos, such that someone who relies on email notifications instead of to-dos doesn't miss anything. We expect a to-do in such a case (newly added mention, whether you're subscribed or not), and so we should also receive an email.

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Asherah Connor

Merge request reports

Loading