Repository: WeblateOrg/weblate

Issue:
Administrative user removal triggers account activity email
### Describe the issue

When removing a user from Weblate, especially e.g. due to a no longer existing email address, Weblate triggers an account activity email towards the deleted user informing the user about private data being removed.

This has two issues:
- The user (is removed by an administrator) is removed for a good reason, e.g. non existend email addresses. This causes additional email bounces
- The user agent and IP address of the administrator are leaked in that email

### I already tried

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

### Steps to reproduce the behavior

As admin
1. Go to admin interface
2. Go to Users tab
3. search the user in question by email address (or username)
4. click on the user in question
5. on the lower end of the mask then click "Delete" and confirm the deletion by another "delete"

--> This fires the activity information.

### Expected behavior

If an administrator removes an account, the account in question does not receive a further email. If that's not an option, the admin should have the control to disable the email notification during the deletion process.

Under no circumstances the IP address of the admin is being leaked.

### Screenshots

![image](https://github.com/WeblateOrg/weblate/assets/6549061/2655e1ff-d8a6-4ddb-b773-1326dbe418b3)


### Exception traceback

```pytb
none
```


### How do you run Weblate?

Docker container

### Weblate versions

 * Weblate: 5.0.2
 * Django: 4.2.5
 * siphashc: 2.1
 * translate-toolkit: 3.10.1
 * lxml: 4.9.3
 * Pillow: 10.0.0
 * nh3: 0.2.14
 * python-dateutil: 2.8.2
 * social-auth-core: 4.4.2
 * social-auth-app-django: 5.3.0
 * django-crispy-forms: 2.0
 * oauthlib: 3.2.2
 * django-compressor: 4.4
 * djangorestframework: 3.14.0
 * django-filter: 23.2
 * django-appconf: 1.0.5
 * user-agents: 2.2.0
 * filelock: 3.12.4
 * rapidfuzz: 3.3.0
 * openpyxl: 3.1.2
 * celery: 5.3.4
 * django-celery-beat: 2.5.0
 * kombu: 5.3.2
 * translation-finder: 2.15
 * weblate-language-data: 2023.5
 * html2text: 2020.1.16
 * pycairo: 1.24.0
 * PyGObject: 3.46.0
 * diff-match-patch: 20230430
 * requests: 2.31.0
 * django-redis: 5.3.0
 * hiredis: 2.2.3
 * sentry-sdk: 1.31.0
 * Cython: 3.0.2
 * misaka: 2.1.1
 * GitPython: 3.1.36
 * borgbackup: 1.2.6
 * pyparsing: 3.1.1
 * ahocorasick_rs: 0.17.1
 * python-redis-lock: 4.0.0
 * charset-normalizer: 3.2.0
 * Python: 3.11.5
 * Git: 2.30.2
 * psycopg2: 2.9.7
 * phply: 1.2.6
 * ruamel.yaml: 0.17.32
 * tesserocr: 2.6.1
 * boto3: 1.28.48
 * zeep: 4.2.1
 * aeidon: 1.12
 * iniparse: 0.5
 * mysqlclient: 2.2.0
 * Mercurial: 6.5.2
 * git-svn: 2.30.2
 * git-review: 2.3.1
 * PostgreSQL server: 15.4
 * Database backends: django.db.backends.postgresql
 * Cache backends: default:RedisCache, avatar:FileBasedCache
 * Email setup: django.core.mail.backends.smtp.EmailBackend: mx2.zammad.com
 * OS encoding: filesystem=utf-8, default=utf-8
 * Celery: redis://cache:6379/1, redis://cache:6379/1, regular
 * Platform: Linux 5.10.0-23-amd64 (x86_64)

### Weblate deploy checks

```shell
System check identified no issues (2 silenced).

(Silenced is: weblate.I021)
```


### Additional context

A side note regarding that mail:
It tells the user to open a bug report on the weblate repo, if the change was not intended by the user.
This is a little bit irritating - shouldn't the user contact the instance administrator in case of issues instead of creating issues on the vendors tracker that might not be able to help (because it might not be Weblate SaaS).


Discussion:

Resolving patch:
diff --git a/weblate/accounts/models.py b/weblate/accounts/models.py
--- a/weblate/accounts/models.py
+++ b/weblate/accounts/models.py
@@ -323,6 +323,7 @@ def should_notify(self):
             and self.user.is_active
             and self.user.email
             and self.activity in NOTIFY_ACTIVITY
+            and not self.params.get("skip_notify")
         )
 
     def check_rate_limit(self, request):
diff --git a/weblate/accounts/utils.py b/weblate/accounts/utils.py
--- a/weblate/accounts/utils.py
+++ b/weblate/accounts/utils.py
@@ -15,13 +15,13 @@
 from weblate.trans.signals import user_pre_delete
 
 
-def remove_user(user, request):
+def remove_user(user, request, **params):
     """Remove user account."""
     # Send signal (to commit any pending changes)
     user_pre_delete.send(instance=user, sender=user.__class__)
 
     # Store activity log and notify
-    AuditLog.objects.create(user, request, "removed")
+    AuditLog.objects.create(user, request, "removed", **params)
 
     # Remove any email validation codes
     invalidate_reset_codes(user)
diff --git a/weblate/accounts/views.py b/weblate/accounts/views.py
--- a/weblate/accounts/views.py
+++ b/weblate/accounts/views.py
@@ -578,7 +578,7 @@ def post(self, request, **kwargs):
                 user.groups.remove(form.cleaned_data["remove_group"])
                 return HttpResponseRedirect(self.get_success_url() + "#groups")
         if "remove_user" in request.POST:
-            remove_user(user, request)
+            remove_user(user, request, skip_notify=True)
             return HttpResponseRedirect(self.get_success_url() + "#groups")
 
         return super().post(request, **kwargs)


Test patch: