Skip to content

Commit 5fd51a6

Browse files
committed
✨ QRESYNC: Add qresync kwarg to #select/#examine [🚧 tests, validate args]
1 parent 5f18cb0 commit 5fd51a6

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

lib/net/imap.rb

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1573,12 +1573,6 @@ def login(user, password)
15731573
# or when existing messages are expunged; see #add_response_handler for a
15741574
# way to detect these events.
15751575
#
1576-
# When the +condstore+ keyword argument is true, the server is told to
1577-
# enable the extension. If +mailbox+ supports persistence of mod-sequences,
1578-
# the +HIGHESTMODSEQ+ ResponseCode will be sent as an untagged response to
1579-
# #select and all `FETCH` responses will include FetchData#modseq.
1580-
# Otherwise, the +NOMODSEQ+ ResponseCode will be sent.
1581-
#
15821576
# A Net::IMAP::NoResponseError is raised if the mailbox does not
15831577
# exist or is for some reason non-selectable.
15841578
#
@@ -1593,9 +1587,22 @@ def login(user, password)
15931587
# imap.responses("NO", &:last)&.code&.name == "UIDNOTSTICKY"
15941588
#
15951589
# If [CONDSTORE[https://www.rfc-editor.org/rfc/rfc7162.html]] is supported,
1596-
# the +condstore+ keyword parameter may be used.
1590+
# the +condstore+ keyword parameter may be used. When the +condstore+
1591+
# keyword argument is true, the server is told to enable the extension. If
1592+
# +mailbox+ supports persistence of mod-sequences, the +HIGHESTMODSEQ+
1593+
# ResponseCode will be sent as an untagged response to #select and all
1594+
# `FETCH` responses will include FetchData#modseq. Otherwise, the
1595+
# +NOMODSEQ+ ResponseCode will be sent.
1596+
#
15971597
# imap.select("mbox", condstore: true)
15981598
# modseq = imap.responses("HIGHESTMODSEQ", &:last)
1599+
#
1600+
# If [QRESYNC[https://www.rfc-editor.org/rfc/rfc7162.html]] is enabled,
1601+
# the +qresync+ keyword parameter may be used. The optional +qresync+
1602+
# argument can provide quick resynchronization parameters: the last known
1603+
# UIDVALIDITY, the last known MODSEQ, <em>(optional)</em> known UIDs, and
1604+
# <em>(optional)</em> message sequence match data.
1605+
#
15991606
def select(...)
16001607
select_internal("SELECT", ...)
16011608
end
@@ -2975,9 +2982,6 @@ def uid_thread(algorithm, search_keys, charset)
29752982
# See {[RFC7162 §3.1]}[https://www.rfc-editor.org/rfc/rfc7162.html#section-3.1].
29762983
#
29772984
# [+QRESYNC+ {[RFC7162]}[https://www.rfc-editor.org/rfc/rfc7162.html]]
2978-
# *NOTE:* The +QRESYNC+ argument to #select and #examine is not supported
2979-
# yet.
2980-
#
29812985
# Adds quick resynchronization options to #select, #examine, and
29822986
# #uid_fetch. +QRESYNC+ _must_ be explicitly enabled before using any of
29832987
# the extension's command parameters. All +EXPUNGE+ responses will be
@@ -3600,9 +3604,12 @@ def enforce_logindisabled?
36003604
end
36013605
end
36023606

3603-
def select_internal(command, mailbox, condstore: false)
3607+
def select_internal(command, mailbox, condstore: false, qresync: nil)
36043608
args = [command, mailbox]
3605-
args << ["CONDSTORE"] if condstore
3609+
params = []
3610+
params << "CONDSTORE" if condstore
3611+
params << "QRESYNC" << qresync if qresync # TODO: validate qresync params
3612+
args << params unless params.empty?
36063613
synchronize do
36073614
state_unselected! # implicitly closes current mailbox
36083615
@responses.clear

0 commit comments

Comments
 (0)