From 26573ad7e67e64d6db222877cf2853920c2c7dae Mon Sep 17 00:00:00 2001 From: David Yip Date: Sun, 3 Jun 2018 19:41:54 -0500 Subject: 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. --- app/models/glitch/keyword_mute_helper.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'app/models/glitch/keyword_mute_helper.rb') diff --git a/app/models/glitch/keyword_mute_helper.rb b/app/models/glitch/keyword_mute_helper.rb index 6d067947f..955c3b1f3 100644 --- a/app/models/glitch/keyword_mute_helper.rb +++ b/app/models/glitch/keyword_mute_helper.rb @@ -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) -- cgit