forked from mirrors/bookwyrm
Fixes bugs in model task
This commit is contained in:
parent
1aa6b99d1f
commit
eb8b9fdaed
1 changed files with 10 additions and 9 deletions
|
@ -84,19 +84,17 @@ def automod_users(reporter):
|
|||
user_rules = AutoMod.objects.filter(flag_users=True).values_list(
|
||||
"string_match", flat=True
|
||||
)
|
||||
if not user_rules:
|
||||
return []
|
||||
|
||||
filters = []
|
||||
for field in ["username", "summary", "name"]:
|
||||
filters += [{f"{field}__icontains": r} for r in user_rules]
|
||||
users = (
|
||||
User.objects.filter(
|
||||
reduce(operator.or_, (Q(**f) for f in filters)),
|
||||
is_active=True,
|
||||
report__isnull=True, # don't flag users that already have reports
|
||||
)
|
||||
.distinct()
|
||||
.values_list("id", flat=True)
|
||||
)
|
||||
users = User.objects.filter(
|
||||
reduce(operator.or_, (Q(**f) for f in filters)),
|
||||
is_active=True,
|
||||
report__isnull=True, # don't flag users that already have reports
|
||||
).distinct()
|
||||
|
||||
report_model = apps.get_model("bookwyrm", "Report", require_ready=True)
|
||||
|
||||
|
@ -118,6 +116,9 @@ def automod_statuses(reporter):
|
|||
"string_match", flat=True
|
||||
)
|
||||
|
||||
if not status_rules:
|
||||
return []
|
||||
|
||||
filters = []
|
||||
for field in ["content", "content_warning", "quotation__quote", "review__name"]:
|
||||
filters += [{f"{field}__icontains": r} for r in status_rules]
|
||||
|
|
Loading…
Reference in a new issue