Skip to content

Commit

Permalink
✨ Allow blocking user based on full name
Browse files Browse the repository at this point in the history
  • Loading branch information
pajowu committed Aug 16, 2024
1 parent 3129173 commit d0da260
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
17 changes: 17 additions & 0 deletions froide/account/migrations/0037_accountblocklist_full_name.py
Original file line number Diff line number Diff line change
@@ -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),
),
]
7 changes: 6 additions & 1 deletion froide/account/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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)
Expand Down

0 comments on commit d0da260

Please sign in to comment.