mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-23 08:36:32 +00:00
Expands scanned fields
This commit is contained in:
parent
93f82fbf18
commit
84b9a19339
1 changed files with 17 additions and 8 deletions
|
@ -85,12 +85,18 @@ def automod_users(reporter):
|
||||||
"string_match", flat=True
|
"string_match", flat=True
|
||||||
)
|
)
|
||||||
|
|
||||||
filters = [{"username__icontains": r} for r in user_rules]
|
filters = []
|
||||||
users = User.objects.filter(
|
for field in ["username", "summary", "name"]:
|
||||||
reduce(operator.or_, (Q(**f) for f in filters)),
|
filters += [{f"{field}__icontains": r} for r in user_rules]
|
||||||
is_active=True,
|
users = (
|
||||||
report__isnull=True, # don't flag users that already have reports
|
User.objects.filter(
|
||||||
).values_list("id", flat=True)
|
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)
|
||||||
|
)
|
||||||
|
|
||||||
report_model = apps.get_model("bookwyrm", "Report", require_ready=True)
|
report_model = apps.get_model("bookwyrm", "Report", require_ready=True)
|
||||||
|
|
||||||
|
@ -112,13 +118,16 @@ def automod_statuses(reporter):
|
||||||
"string_match", flat=True
|
"string_match", flat=True
|
||||||
)
|
)
|
||||||
|
|
||||||
filters = [{"content__icontains": r} for r in status_rules]
|
filters = []
|
||||||
|
for field in ["content", "content_warning", "quotation__quote", "review__name"]:
|
||||||
|
filters += [{f"{field}__icontains": r} for r in status_rules]
|
||||||
|
|
||||||
status_model = apps.get_model("bookwyrm", "Status", require_ready=True)
|
status_model = apps.get_model("bookwyrm", "Status", require_ready=True)
|
||||||
statuses = status_model.objects.filter(
|
statuses = status_model.objects.filter(
|
||||||
reduce(operator.or_, (Q(**f) for f in filters)),
|
reduce(operator.or_, (Q(**f) for f in filters)),
|
||||||
deleted=False,
|
deleted=False,
|
||||||
report__isnull=True, # don't flag statuses that already have reports
|
report__isnull=True, # don't flag statuses that already have reports
|
||||||
)
|
).distinct()
|
||||||
|
|
||||||
report_model = apps.get_model("bookwyrm", "Report", require_ready=True)
|
report_model = apps.get_model("bookwyrm", "Report", require_ready=True)
|
||||||
return report_model.objects.bulk_create(
|
return report_model.objects.bulk_create(
|
||||||
|
|
Loading…
Reference in a new issue