mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-01-15 01:48:18 -05:00
AutoMod: error if invalid search check for type
If all of the fields in a search check are invalid for a type, we should throw an error instead of just quietly disregarding that search check. The previous behavior caused a rule with, for example, separate searches for both "domain" and "body" to apply to comments, even though the presence of a domain check should have caused it to be restricted to only submissions.
This commit is contained in:
@@ -620,6 +620,12 @@ class RuleTarget(object):
|
||||
valid_fields = self._match_fields_by_type[self.target_type]
|
||||
fields = {field for field in fields if field in valid_fields}
|
||||
|
||||
if not fields:
|
||||
raise AutoModeratorRuleTypeError(
|
||||
"Can't search `%s` on this type" % key,
|
||||
self.parent.yaml,
|
||||
)
|
||||
|
||||
modifiers = matches.group(2)
|
||||
if modifiers:
|
||||
modifiers = [mod.strip() for mod in modifiers.split(",")]
|
||||
|
||||
Reference in New Issue
Block a user