Repository: mozilla/pontoon

Issue:
[notifications] Notify project Translators when suggestions are submitted
*This issue was created automatically by a [script](https://github.com/mathjazz/bugzilla2github/).*
## [Bug 1398861](https://bugzilla.mozilla.org/show_bug.cgi?id=1398861)
Bug Reporter: @mathjazz
CC:   @MikkCZ, mvasicek@mozilla.cz
See also:     https://bugzilla.mozilla.org/show_bug.cgi?id=1625102

We should probably do that periodically and aggregate notifications.


Discussion:
Comment Author: @mathjazz

*** Bug #1403303 has been marked as a duplicate of this bug. ***


Comment Author: @mathjazz

We should also notify comment authors.


Comment Author: @mathjazz

*** Bug #1625102 has been marked as a duplicate of this bug. ***


Quick spec:

A daily job sends notifications about newly created unreviewed suggestions that are submitted, unapproved or unrejected in the last 24 hours. Recipients of notifications are users with permission to review them, as well as authors of any previous translations or comments of the same string.

Recipient gets only one notification per job, with all project-locale combinations aggregated. Example:

*Unreviewed suggestions have been submitted for the following projects:*
- *[Firefox for Android](https://pontoon.mozilla.org/sl/firefox-for-android/all-resources/?status=unreviewed)*
- *[Mozilla.org](https://pontoon.mozilla.org/sl/mozillaorg/all-resources/?status=unreviewed)*

@flodolo @Delphine @peiying2 r?
Is it 24 hours too often, given users can't opt out of notifications? 
What happens is a suggestion is submitted but already approved within the interval? I assume we wouldn't send anything in that case?
I think every 24h is going to be to much noise for localizers. Could once a week already be enough?
> What happens is a suggestion is submitted but already approved within the interval? I assume we wouldn't send anything in that case?

Your assumption is correct. 
> Recipients of notifications are users with permission to review them

This would be project managers and language team coordinators? (Sorry, don't know the Pontoon terms by heart.)
It's team Managers and Translators:
https://mozilla-l10n.github.io/localizer-documentation/tools/pontoon/users.html#user-roles
24-hour cycle seems to be frequent, but most people don't check Pontoon daily. We also assume people translate/review in Pontoon daily in all the projects. I personally don't object it it. 

Resolving patch:
diff --git a/pontoon/projects/management/commands/send_suggestion_notifications.py b/pontoon/projects/management/commands/send_suggestion_notifications.py
--- a/pontoon/projects/management/commands/send_suggestion_notifications.py
+++ b/pontoon/projects/management/commands/send_suggestion_notifications.py
@@ -107,11 +107,13 @@ def handle(self, *args, **options):
             self.extract_notifications_data(data, suggestion)
 
         for recipient, project_locales in data.items():
-            verb = render_to_string(
+            description = render_to_string(
                 "projects/suggestion_notification.jinja",
                 {"project_locales": project_locales},
             )
 
-            notify.send(recipient, recipient=recipient, verb=verb)
+            notify.send(
+                recipient, recipient=recipient, verb="", description=description
+            )
 
-        self.stdout.write("Suggestion notifications sent.")
+        self.stdout.write(f"Suggestion notifications sent to {len(data)} users.")


Test patch: