From d0da260dd97780471a128609ff8e9e127e2cdd88 Mon Sep 17 00:00:00 2001 From: Kara Engelhardt Date: Thu, 15 Aug 2024 18:54:20 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Allow=20blocking=20user=20based=20o?= =?UTF-8?q?n=20full=20name?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../0037_accountblocklist_full_name.py | 17 +++++++++++++++++ froide/account/models.py | 7 ++++++- 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 froide/account/migrations/0037_accountblocklist_full_name.py diff --git a/froide/account/migrations/0037_accountblocklist_full_name.py b/froide/account/migrations/0037_accountblocklist_full_name.py new file mode 100644 index 000000000..f988e1e92 --- /dev/null +++ b/froide/account/migrations/0037_accountblocklist_full_name.py @@ -0,0 +1,17 @@ +# Generated by Django 4.2.14 on 2024-08-15 16:17 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("account", "0036_alter_application_user_alter_user_email_and_more"), + ] + + operations = [ + migrations.AddField( + model_name="accountblocklist", + name="full_name", + field=models.TextField(blank=True), + ), + ] diff --git a/froide/account/models.py b/froide/account/models.py index 7433a3313..345090251 100644 --- a/froide/account/models.py +++ b/froide/account/models.py @@ -400,6 +400,7 @@ class AccountBlocklist(models.Model): address = models.TextField(blank=True) email = models.TextField(blank=True) + full_name = models.TextField(blank=True) objects = AccountBlocklistManager() @@ -411,7 +412,11 @@ def __str__(self): return self.name def match_user(self, user: User) -> bool: - return self.match_field(user, "address") or self.match_field(user, "email") + return ( + self.match_field(user, "address") + or self.match_field(user, "email") + or self.match_content(self.full_name, user.get_full_name()) + ) def match_field(self, user: User, key: str) -> bool: content = getattr(self, key)