diff --git a/bookwyrm/models/antispam.py b/bookwyrm/models/antispam.py index 4632c64ee..b894ade77 100644 --- a/bookwyrm/models/antispam.py +++ b/bookwyrm/models/antispam.py @@ -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]