aboutsummaryrefslogtreecommitdiff
path: root/filters
diff options
context:
space:
mode:
authormms <git@sapka.me>2024-11-25 13:02:20 +0100
committermms <git@sapka.me>2024-11-25 13:02:20 +0100
commit4c911a441e9533b5bb323b26be748abfd4c5d316 (patch)
treea69e6875b00388b83620e97d8e274cb7dc1e4a7a /filters
parentfcdfb62d0f9ca9773da57e20286b8623c2c866f5 (diff)
fix: handle incorrect mailing list ids
Diffstat (limited to 'filters')
-rw-r--r--filters/mailing_lists_filter.rb10
1 files changed, 9 insertions, 1 deletions
diff --git a/filters/mailing_lists_filter.rb b/filters/mailing_lists_filter.rb
index 872a817..feaee0e 100644
--- a/filters/mailing_lists_filter.rb
+++ b/filters/mailing_lists_filter.rb
@@ -5,7 +5,12 @@ module Chotto
# Baed on RFC 2919
module MailingListsFilter
def self.list_id_from_header(value)
- value.match(/<(.*)>/)[1].gsub(' ', '')
+ id = value.match(/<(.*)>/)
+ if id
+ id[1]&.gsub(' ', '')
+ else
+ value
+ end
end
end
end
@@ -13,9 +18,12 @@ end
MAILING_LIST_FILTER = lambda do
Chotto.rule_set 'mailing_lists' do
messages.filter('NOT tag:lists').each do |msg|
+ unless msg.list_id.empty?
+
list_id = Chotto::MailingListsFilter.list_id_from_header(msg.list_id)
msg.tags = ['unread', 'inbox', 'lists', "lists/#{list_id}"]
msg.save!
+ end
end
end
end