# 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