Thread scopes through #matches?. #454.

Also add an apply_to_mentions attribute on Glitch::KeywordMute, which is
used to calculate scope.  Next up: additions to the test suite to
demonstrate how scoping works.
This commit is contained in:
David Yip
2018-06-03 19:41:54 -05:00
parent 37d495eeeb
commit 26573ad7e6
8 changed files with 99 additions and 61 deletions

View File

@@ -9,16 +9,16 @@ class Glitch::KeywordMuteHelper
@tag_matcher = Glitch::KeywordMute.tag_matcher_for(receiver_id)
end
def matches?(status)
matchers_match?(status) || (status.reblog? && matchers_match?(status.reblog))
def matches?(status, scope)
matchers_match?(status, scope) || (status.reblog? && matchers_match?(status.reblog, scope))
end
private
def matchers_match?(status)
text_matcher.matches?(prepare_text(status.text)) ||
text_matcher.matches?(prepare_text(status.spoiler_text)) ||
tag_matcher.matches?(status.tags)
def matchers_match?(status, scope)
text_matcher.matches?(prepare_text(status.text), scope) ||
text_matcher.matches?(prepare_text(status.spoiler_text), scope) ||
tag_matcher.matches?(status.tags, scope)
end
def prepare_text(text)