Repository: WeblateOrg/weblate

Issue:
No notification when source strings are added or updated
### Describe the issue

When a source strings get's updated or added in a component through a git commit in the en-GB "Monolingual base language file", then no notification mail goes out. In the notification settings I'v set "New string is available for translation" and "String was changed" to instant notification. Do I miss here something or is this a bug?

### I already tried

- [X] I've read and searched [the documentation](https://docs.weblate.org/).
- [x] I've searched for similar filed issues in this repository.

### Steps to reproduce the behavior

1. Choose a translated language in the user settings
2. Watch a project in the user settings
3. Set all notifications to Instant in the user settings
4. Commit a new string and an update string in a base monolingual file

### Expected behavior

A notification mail goes out to the user.

### Screenshots

![image](https://github.com/WeblateOrg/weblate/assets/251072/39ffcda6-ba13-438b-8385-8460e5f5b66a)


### Exception traceback

_No response_

### How do you run Weblate?

Docker container

### Weblate versions

5.3

### Weblate deploy checks

_No response_

### Additional context

_No response_


Discussion:
There is currently no notification for source string being changed. Closest to that is "Unfinished strings exist" as that will trigger when some string will need a translation.
Any plan to integrate this? Coming from Transifex this is one of the key features, as rarely no translators are polling weblate for changes. It keeps them engaged.
This seems like a duplicate of https://github.com/WeblateOrg/weblate/issues/5602. Can you please review that and close this if this is really the case?
Not really, mine is more about notifications and not about pending tasks.
Or is there another way a translator who watches a project gets a notification when a source string has change or is added?
@nijel @laoneo I can confirm that it's a bug. I haven't changed anything in the settings, but some time ago, I stopped receiving any emails about new strings to translate or that someone translated something. I am only receiving notifications about new comments or new components.
@laoneo The notification for new string is there (New string is available for translation), the notification when source string changes is not there.

@Aga-C Unfortunately, we're not talking about a bug here, but about a missing feature. If you see a bug, please open a separate issue for that and provide more information (especially what notifications you have configured).
Thanks @nijel , but I do not get a mail when a new string is added either after a git rebase from the github webhook.
@nijel how big is the chance that you will implement this feature request that when a source string is update that notification mails are going out? With this change you can catch up to the big providers like transifex or crowdin as this is an important feature to keep the translators engaged.
> @laoneo The notification for new string is there (New string is available for translation), the notification when source string changes is not there.

This doesn't work on self hosted weblate. Should I open a bug report for this? Just that I do not miss here something. I'm adding a new string to the monolingual file and push it to the git repo. Then weblate updates but no mail is going out that there are new strings available for translation.
You're right, the strings added in the repository do not trigger the notification, https://github.com/WeblateOrg/weblate/pull/10659 should address this.
This issue has been automatically marked as stale because there wasn’t any recent activity.

It will be closed soon if no further action occurs.

Thank you for your contributions!
@nijel is it possible the issue wasn't completely solved? I'm testing locally version `5.3.1+2024-01-31` (which includes #10659). Adding a new string to the repo still does not trigger the notification, even though the setting `New string is available for translation` is set to `Instant notification`. (I do get a `Repository operation` notification.)

Rolling back to version 4.18.2 works. That is, with the same app data folder and database, adding a new string to the repo successfully sends a `New string to translate` notification.
The issue indeed isn't completely solved as it is still open.

Do you see "String added in the repository" event in the string history?

Ahh... I see. Yes indeed, the event is there:
![image](https://github.com/WeblateOrg/weblate/assets/64745/81609f4a-44f7-442e-9fed-f350e22aee5b)

https://github.com/WeblateOrg/weblate/pull/11002 should fix the new string notification not being sent.
Thanks, so only update is missing and then can this issue being closed?
Yes.
Ok, then I wait with closing this issue.

Resolving patch:
diff --git a/weblate/accounts/migrations/0010_alter_subscription_notification.py b/weblate/accounts/migrations/0010_alter_subscription_notification.py
new file mode 100644
--- /dev/null
+++ b/weblate/accounts/migrations/0010_alter_subscription_notification.py
@@ -0,0 +1,60 @@
+# Copyright © Michal Čihař <michal@weblate.org>
+#
+# SPDX-License-Identifier: GPL-3.0-or-later
+
+# Generated by Django 5.0.3 on 2024-05-15 06:04
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+    dependencies = [
+        ("accounts", "0009_alter_profile_dashboard_view"),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name="subscription",
+            name="notification",
+            field=models.CharField(
+                choices=[
+                    (
+                        "RepositoryNotification",
+                        "Operation was performed in the repository",
+                    ),
+                    ("LockNotification", "Component was locked or unlocked"),
+                    ("LicenseNotification", "License was changed"),
+                    ("ParseErrorNotification", "Parse error occurred"),
+                    ("NewStringNotificaton", "String is available for translation"),
+                    (
+                        "NewContributorNotificaton",
+                        "Contributor made their first translation",
+                    ),
+                    ("NewSuggestionNotificaton", "Suggestion was added"),
+                    ("NewCommentNotificaton", "Comment was added"),
+                    ("MentionCommentNotificaton", "You were mentioned in a comment"),
+                    (
+                        "LastAuthorCommentNotificaton",
+                        "Your translation received a comment",
+                    ),
+                    ("TranslatedStringNotificaton", "String was edited by user"),
+                    ("ApprovedStringNotificaton", "String was approved"),
+                    ("ChangedStringNotificaton", "String was changed"),
+                    (
+                        "NewTranslationNotificaton",
+                        "New language was added or requested",
+                    ),
+                    (
+                        "NewComponentNotificaton",
+                        "New translation component was created",
+                    ),
+                    ("NewAnnouncementNotificaton", "Announcement was published"),
+                    ("NewAlertNotificaton", "New alert emerged in a component"),
+                    ("MergeFailureNotification", "Repository operation failed"),
+                    ("PendingSuggestionsNotification", "Pending suggestions exist"),
+                    ("ToDoStringsNotification", "Unfinished strings exist"),
+                ],
+                max_length=100,
+            ),
+        ),
+    ]
diff --git a/weblate/accounts/notifications.py b/weblate/accounts/notifications.py
--- a/weblate/accounts/notifications.py
+++ b/weblate/accounts/notifications.py
@@ -497,10 +497,13 @@ def get_context(
 
 @register_notification
 class NewStringNotificaton(Notification):
-    actions = (Change.ACTION_NEW_UNIT, Change.ACTION_NEW_UNIT_REPO)
-    verbose = pgettext_lazy(
-        "Notification name", "New string is available for translation"
+    actions = (
+        Change.ACTION_NEW_UNIT,
+        Change.ACTION_NEW_UNIT_REPO,
+        Change.ACTION_MARKED_EDIT,
+        Change.ACTION_SOURCE_CHANGE,
     )
+    verbose = pgettext_lazy("Notification name", "String is available for translation")
     template_name = "new_string"
     filter_languages = True
     required_attr = "unit"


Test patch:
diff --git a/weblate/accounts/tests/test_notifications.py b/weblate/accounts/tests/test_notifications.py
--- a/weblate/accounts/tests/test_notifications.py
+++ b/weblate/accounts/tests/test_notifications.py
@@ -192,7 +192,7 @@ def test_notify_new_string(self) -> None:
 
         # Check mail
         self.validate_notifications(
-            1, "[Weblate] New string to translate in Test/Test — Czech"
+            1, "[Weblate] String to translate in Test/Test — Czech"
         )
 
     def test_notify_new_translation(self) -> None: