Просмотр исходного кода

Fixes #5361 - Fetching mails with protonmail-bridge is not possible due to closed stream error.

Co-authored-by: Florian Liebe <fl@zammad.com>
Co-authored-by: Tobias Schäfer <ts@zammad.com>
Florian Liebe 4 месяцев назад
Родитель
Сommit
3f31b555f1
2 измененных файлов с 23 добавлено и 0 удалено
  1. 2 0
      app/models/channel/driver/imap.rb
  2. 21 0
      spec/models/channel/driver/imap_spec.rb

+ 2 - 0
app/models/channel/driver/imap.rb

@@ -411,6 +411,8 @@ example
   end
 
   def fetch_message_ids(filter)
+    raise if @imap.capabilities.exclude?('SORT')
+
     {
       result:      @imap.sort(['DATE'], filter, 'US-ASCII'),
       is_fallback: false

+ 21 - 0
spec/models/channel/driver/imap_spec.rb

@@ -222,6 +222,27 @@ RSpec.describe Channel::Driver::Imap, integration: true, required_envs: %w[MAIL_
           expect_imap_fetch_check_results({ archive_possible: true, archive_possible_is_fallback: false })
         end
       end
+
+      context 'without sort capability' do
+        before do
+          allow_any_instance_of(Net::IMAP).to receive(:capabilities).and_return(%w[ID IDLE IMAP4REV1 MOVE STARTTLS UIDPLUS UNSELECT])
+        end
+
+        it 'with dateless mail' do
+          imap.append(folder, email_without_date, [], Time.zone.now)
+          expect_imap_fetch_check_results({ archive_possible: true, archive_possible_is_fallback: true })
+        end
+
+        it 'with now dated mail' do
+          imap.append(folder, email_now_date, [], Time.zone.now)
+          expect_imap_fetch_check_results({ archive_possible: true, archive_possible_is_fallback: true })
+        end
+
+        it 'with old dated mail' do
+          imap.append(folder, email_old_date, [], Time.zone.now)
+          expect_imap_fetch_check_results({ archive_possible: true, archive_possible_is_fallback: false })
+        end
+      end
     end
 
     context 'when fetching regular emails' do