Skip to content

Commit c107088

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

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

lib/net/imap.rb

Lines changed: 20 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
@@ -2954,9 +2961,7 @@ def uid_thread(algorithm, search_keys, charset)
29542961
# See {[RFC7162 §3.1]}[https://www.rfc-editor.org/rfc/rfc7162.html#section-3.1].
29552962
#
29562963
# [+QRESYNC+ {[RFC7162]}[https://www.rfc-editor.org/rfc/rfc7162.html]]
2957-
# *NOTE:* Enabling QRESYNC will replace +EXPUNGE+ with +VANISHED+, but
2958-
# the extension arguments to #select, #examine, and #uid_fetch are not
2959-
# supported yet.
2964+
# *NOTE:* The +QRESYNC+ argument to #uid_fetch is not supported yet.
29602965
#
29612966
# Adds quick resynchronization options to #select, #examine, and
29622967
# #uid_fetch. +QRESYNC+ _must_ be explicitly enabled before using any of
@@ -3580,9 +3585,12 @@ def enforce_logindisabled?
35803585
end
35813586
end
35823587

3583-
def select_internal(command, mailbox, condstore: false)
3588+
def select_internal(command, mailbox, condstore: false, qresync: nil)
35843589
args = [command, mailbox]
3585-
args << ["CONDSTORE"] if condstore
3590+
params = []
3591+
params << "CONDSTORE" if condstore
3592+
params << "QRESYNC" << qresync if qresync # TODO: validate qresync params
3593+
args << params unless params.empty?
35863594
synchronize do
35873595
state_unselected! # implicitly closes current mailbox
35883596
@responses.clear

0 commit comments

Comments
 (0)