about summary refs log tree commit diff
path: root/app/models/glitch
AgeCommit message (Collapse)Author
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.