Skip to content

Commit 36f1381

Browse files
committed
✨ Add support for MAILBOXID response code
1 parent ec208e3 commit 36f1381

File tree

4 files changed

+33
-0
lines changed

4 files changed

+33
-0
lines changed

lib/net/imap.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,8 @@ module Net
505505
# - See #enable for information about support for UTF-8 string encoding.
506506
#
507507
# ==== RFC8474: +OBJECTID+
508+
# - Adds +MAILBOXID+ ResponseCode to #create tagged response.
509+
# - Adds +MAILBOXID+ ResponseCode to #select and #examine untagged response.
508510
# - Updates #fetch and #uid_fetch with the +EMAILID+ and +THREADID+ items.
509511
# See FetchData#emailid and FetchData#emailid.
510512
# >>>

lib/net/imap/response_data.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,10 @@ class ResponseText < Struct.new(:code, :text)
256256
# * +ALREADYEXISTS+
257257
# * +NONEXISTENT+
258258
#
259+
# Other supported \IMAP extension response codes:
260+
# * +OBJECTID+ {[RFC8474]}[https://www.rfc-editor.org/rfc/rfc8474.html#section-7]
261+
# * +MAILBOXID+, #data will be a string
262+
#
259263
class ResponseCode < Struct.new(:name, :data)
260264
##
261265
# method: name

lib/net/imap/response_parser.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1794,6 +1794,9 @@ def resp_text
17941794
# resp-text-code =/ "HIGHESTMODSEQ" SP mod-sequence-value /
17951795
# "NOMODSEQ" /
17961796
# "MODIFIED" SP sequence-set
1797+
#
1798+
# RFC8474: OBJECTID
1799+
# resp-text-code =/ "MAILBOXID" SP "(" objectid ")"
17971800
def resp_text_code
17981801
name = resp_text_code__name
17991802
data =
@@ -1813,6 +1816,7 @@ def resp_text_code
18131816
"LIMIT", "OVERQUOTA", "ALREADYEXISTS", "NONEXISTENT", "CLOSED",
18141817
"NOTSAVED", "UIDNOTSTICKY", "UNKNOWN-CTE", "HASCHILDREN"
18151818
when "NOMODSEQ" # CONDSTORE
1819+
when "MAILBOXID" then SP!; parens__objectid # RFC8474: OBJECTID
18161820
else
18171821
SP? and text_chars_except_rbra
18181822
end

test/net/imap/fixtures/response_parser/rfc8474_objectid_responses.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,28 @@
11
---
22
:tests:
3+
rfc8474_example_4.1_MAILBOXID_response_to_CREATE:
4+
:response: "3 OK [MAILBOXID (F2212ea87-6097-4256-9d51-71338625)] Completed\r\n"
5+
:expected: !ruby/struct:Net::IMAP::TaggedResponse
6+
tag: '3'
7+
name: OK
8+
data: !ruby/struct:Net::IMAP::ResponseText
9+
code: !ruby/struct:Net::IMAP::ResponseCode
10+
name: MAILBOXID
11+
data: F2212ea87-6097-4256-9d51-71338625
12+
text: Completed
13+
raw_data: "3 OK [MAILBOXID (F2212ea87-6097-4256-9d51-71338625)] Completed\r\n"
14+
15+
rfc8474_example_4.2_MAILBOXID_untagged_response_to_SELECT:
16+
:response: "* OK [MAILBOXID (F2212ea87-6097-4256-9d51-71338625)] Ok\r\n"
17+
:expected: !ruby/struct:Net::IMAP::UntaggedResponse
18+
name: OK
19+
data: !ruby/struct:Net::IMAP::ResponseText
20+
code: !ruby/struct:Net::IMAP::ResponseCode
21+
name: MAILBOXID
22+
data: F2212ea87-6097-4256-9d51-71338625
23+
text: Ok
24+
raw_data: "* OK [MAILBOXID (F2212ea87-6097-4256-9d51-71338625)] Ok\r\n"
25+
326
rfc8474_example_5.3_EMAILID_and_THREADID:
427
:response: "* 3 FETCH (EMAILID (M5fdc09b49ea703) THREADID (T11863d02dd95b5))\r\n"
528
:expected: !ruby/struct:Net::IMAP::UntaggedResponse

0 commit comments

Comments
 (0)