about summary refs log tree commit diff
path: root/app/models/glitch/keyword_mute.rb
AgeCommit message (Collapse)Author
2018-07-09Migrate glitch-soc keyword mutes to Mastodon'sThibaut Girka
Completely remove glitch-soc's Keyword Mutes, migrate existing database records to CustomFilters. Handling of client-side filters is still not implemented in the glitch-soc front-end.
2018-06-12Merge remote-tracking branch 'glitchsoc/master' into ↵David Yip
454-allow-keyword-mutes-to-skip-mentions Conflicts: app/models/glitch/keyword_mute.rb
2018-06-05Escape metacharacters in non-whole-word keyword mutes. Fixes #533.David Yip
Also addresses #463.
2018-06-03Thread scopes through #matches?. #454.David Yip
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.
2018-06-03keyword mute: Store keywords as a listDavid Yip
This has a couple of advantages over the regex approach: - Keywords are individually addressable, which makes it easier to gather statistics (#363) - Keywords can be individually applied to different feeds, e.g. skipping mentions (#454) It *does* end up creating many more Regexp objects. I'm not yet sure if the difference is significant.
2018-05-04Escape metachars in keywordsDaggertooth
2018-04-30Also treat non-whole-word mutes as case-insensitive. #450.David Yip
2017-11-15Replace =~ with #matches?. #208.David Yip
=~ made sense when we were passing it through to a regex, but we're no longer doing that: TagMatcher looks at individual tags and returns a value that *looks* like what you get out of #=~ but really isn't that meaningful. Probably a good idea to not subvert convention like this and instead use a name with guessable intent.
2017-11-15Prefix cache keys with the matcher type. #208.David Yip
We already know about one regex limitation, which is that they cannot segment words in e.g. Japanese, Chinese, or Thai. It may also end up that regex matching is too slow compared to other methods. However, the regex is an implementation detail. We still want the ability to switch between "occurs anywhere" and "match whole word", and caching the matcher result is likely to still be important (since the matcher itself won't change nearly as often as status ingress rate). Therefore, we ought to be able to change the cache keys to reflect a change of data structure. (Old cache keys expire within minutes, so they shouldn't be too big of an issue. Old cache keys could also be explicitly removed by an instance administrator.)
2017-11-15Match keyword mute filter on hashtags. #208.David Yip
It is reasonable to expect someone to enter #foo to mute hashtag #foo. However, tags are recorded on statuses without the preceding #. To adjust for this, we build a separate tag matcher and use Tag::HASHTAG_RE to extract a hashtag from the hashtag syntax.
2017-11-13Maintain case-insensitivity when merging multiple matchers (#213)David Yip
When given two regexps, Regexp.union preserves the options set (or not set) on each regex; this meant that none of the multiline (m), case-insensitivity (i), or extended syntax (x) options were set. Our regexps are written expecting the m, i, and x options were set on all of them, so we need to make sure that we preserve that behavior.
2017-10-24Remove nil check in Glitch::KeywordMute#=~.David Yip
@regex can no longer be nil, so we don't need to check it.
2017-10-24Switch to Regexp.union for building the mute expression.David Yip
Also make the keyword-building methods private: they always probably should have been private, but now I have encoded enough fun and games into them that it now seems wrong for them to *not* be private.
2017-10-23Only cache the regex text, not the regex itself.David Yip
It is possible to cache a Regexp object, but I'm not sure what happens if e.g. that object remains in cache across two different Ruby versions. Caching a string seems to raise fewer questions.
2017-10-22KeywordMute matcher: more closely mimic Regexp#=~ behavior.David Yip
Regexp#=~ returns nil if it does not match. An empty mute set does not match any status, so KeywordMute::Matcher#=~ ought to return nil also.
2017-10-22Don't add \b to whole-word keywords that don't start with word characters.David Yip
Ditto for ending with \b. Consider muting the phrase "(hot take)". I stipulate it is reasonable to enter this with the default "match whole word" behavior. Under the old behavior, this would be encoded as \b\(hot\ take\)\b However, if \b is before the first character in the string and the first character in the string is not a word character, then the match will fail. Ditto for after. In our example, "(" is not a word character, so this will not match statuses containing "(hot take)", and that's a very surprising behavior. To address this, we only add leading and trailing \b to keywords that start or end with word characters.
2017-10-21Apply keyword mutes to reblogs.David Yip
2017-10-21Move KeywordMute into Glitch namespace.David Yip
There are two motivations for this: 1. It looks like we're going to add other features that require server-side storage (e.g. user notes). 2. Namespacing glitchsoc modifications is a good idea anyway: even if we do not end up doing (1), if upstream introduces a keyword-mute feature that also uses a "KeywordMute" model, we can avoid some merge conflicts this way and work on the more interesting task of choosing which implementation to use.