Skip to content

Commit 99431f6

Browse files
committed
AutoMod: fix needs_media_data for compound checks
Previously, a rule would be considered to need media data if any checks included a media check at all. For example, a check that looked at both the submission's title and the media_title for a particular word would not be applied to posts without media data. However, when in a compound check like this, we should consider the media data optional, since there are other non-media places that can be checked without it. This commit does that, changing it so that a check will only cause the rule to require media data if ALL of the fields being checked come from the media, instead of if ANY of them do.
1 parent dc16d77 commit 99431f6

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

r2/r2/lib/automoderator.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -718,8 +718,10 @@ def get_match_patterns(self, values):
718718
@property
719719
def needs_media_data(self):
720720
"""Whether the component requires data from the media embed."""
721-
if any(field.startswith("media_") for field in self.match_fields):
722-
return True
721+
for key in self.match_patterns:
722+
fields = self.parse_match_fields_key(key)["fields"]
723+
if all(field.startswith("media_") for field in fields):
724+
return True
723725

724726
# check if any of the fields that support placeholders have media ones
725727
potential_placeholders = [self.report_reason]

0 commit comments

Comments
 (0)