diff options
Diffstat (limited to 'filters/spam_filter.rb')
-rw-r--r-- | filters/spam_filter.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/filters/spam_filter.rb b/filters/spam_filter.rb new file mode 100644 index 0000000..ef3ba9e --- /dev/null +++ b/filters/spam_filter.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +SPAM_THRESHOLD = 5.0 + +SPAM_FILTER = lambda do + Chotto.rule_set 'spam_filter' do + messages.filter('NOT tag:spam').each do |msg| + if msg.x_spam_score.to_f > SPAM_THRESHOLD + tags = [ + 'spam', + "spam/#{msg.x_spam_score}" + ] + + msg.tags = tags + msg.save! + + end + + # TODO: understand why sometimes Notmuch raises MemoryErrpr + rescue Notmuch::MemoryError + end + end +end |