diff options
author | Koni Marti <koni.marti@gmail.com> | 2023-06-23 22:39:43 +0200 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2023-06-25 22:34:00 +0200 |
commit | 9d0fdffeef2f4ae1f8c1b57f558e68ba4bd9ad28 (patch) | |
tree | c9be2024af6cde9d523e1fd63ac497aec2e31879 | |
parent | d860e26629fd1d59539201a53f4af3eef9f14ccf (diff) | |
download | aerc-9d0fdffeef2f4ae1f8c1b57f558e68ba4bd9ad28.tar.gz |
imap: only call UidSort with sort criteria
Only call UidSort with some sort criteria. If we call it without,
some imap severs report it as an error.
For example, Fastmail imap with the sort config in aerc.conf commented
out reports: "[Fastmail] unexpected error: Missing Sort criteria" and
cannot display the messages.
Fixes: https://lists.sr.ht/~rjarry/aerc-devel/%3C5955665f-4d1a-4295-86bd-d1a5eabd0d6d%40milic.suse.cz%3E
Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
-rw-r--r-- | worker/imap/open.go | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/worker/imap/open.go b/worker/imap/open.go index 3ad9fc9d..693d93a9 100644 --- a/worker/imap/open.go +++ b/worker/imap/open.go @@ -48,12 +48,13 @@ func (imapw *IMAPWorker) handleFetchDirectoryContents( return } sortCriteria := translateSortCriterions(msg.SortCriteria) + hasSortCriteria := len(sortCriteria) > 0 var uids []uint32 // If the server supports the SORT extension, do the sorting server side switch { - case imapw.caps.Sort: + case imapw.caps.Sort && hasSortCriteria: uids, err = imapw.client.sort.UidSort(sortCriteria, searchCriteria) if err != nil { imapw.worker.PostMessage(&types.Error{ @@ -67,7 +68,7 @@ func (imapw *IMAPWorker) handleFetchDirectoryContents( uids[i], uids[j] = uids[j], uids[i] } default: - if len(sortCriteria) > 0 { + if hasSortCriteria { imapw.worker.Warnf("SORT is not supported but requested: list messages by UID") } uids, err = imapw.client.UidSearch(searchCriteria) |