Skip to content

Commit

Permalink
Merge pull request #1611 from nevans/fix-imap-search-issues
Browse files Browse the repository at this point in the history
Fix IMAP search issues
  • Loading branch information
eval authored Jun 5, 2024
2 parents 4f679ec + c779866 commit 1fe6b59
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/mail/network/retriever_methods/imap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,10 @@ def find(options=nil, &block)

start do |imap|
options[:read_only] ? imap.examine(options[:mailbox]) : imap.select(options[:mailbox])

uids = imap.uid_search(options[:keys], options[:search_charset])
.to_a # older net-imap may return nil, newer may return ESearchResult struct
.sort # RFC3501 does _not_ require UIDs to be returned in order
uids.reverse! if options[:what].to_sym == :last
uids = uids.first(options[:count]) if options[:count].is_a?(Integer)
uids.reverse! if (options[:what].to_sym == :last && options[:order].to_sym == :asc) ||
Expand Down

0 comments on commit 1fe6b59

Please sign in to comment.