Skip to content

Commit

Permalink
AutoMod: fix needs_media_data for compound checks
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Deimos committed May 18, 2015
1 parent dc16d77 commit 99431f6
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions r2/r2/lib/automoderator.py
Original file line number Diff line number Diff line change
Expand Up @@ -718,8 +718,10 @@ def get_match_patterns(self, values):
@property
def needs_media_data(self):
"""Whether the component requires data from the media embed."""
if any(field.startswith("media_") for field in self.match_fields):
return True
for key in self.match_patterns:
fields = self.parse_match_fields_key(key)["fields"]
if all(field.startswith("media_") for field in fields):
return True

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

0 comments on commit 99431f6

Please sign in to comment.