fixes #2418 (includes hiding deleted dmails and allowing filtering on user name)

This commit is contained in:
r888888888
2015-07-07 16:47:23 -07:00
parent 4a24fe5074
commit 67e46f6e5c
9 changed files with 121 additions and 8 deletions

View File

@@ -11,7 +11,7 @@ class DmailFilter < ActiveRecord::Base
end
def filtered?(dmail)
dmail.from.level <= User::Levels::MODERATOR && has_filter? && (dmail.body =~ regexp || dmail.title =~ regexp)
dmail.from.level <= User::Levels::MODERATOR && has_filter? && (dmail.body =~ regexp || dmail.title =~ regexp || dmail.from.name =~ regexp)
end
def has_filter?
@@ -19,6 +19,6 @@ class DmailFilter < ActiveRecord::Base
end
def regexp
@regexp ||= Regexp.compile(words.scan(/\S+/).map {|x| Regexp.escape(x)}.join("|"))
@regexp ||= Regexp.compile('\b(?:' + words.scan(/\S+/).map {|x| Regexp.escape(x)}.join("|") + ')\b')
end
end