From cb444ffe003978ea0ee860a96a45f06ef3ad758e Mon Sep 17 00:00:00 2001 From: nicholas evans Date: Mon, 1 Jan 2024 21:49:10 -0500 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Forward=20all=20search/uid?= =?UTF-8?q?=5Fsearch=20arguments?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Forward all `#search` and `#uid_search` arguments to `#search_internal`. This simplifies future changes to search parameters. --- lib/net/imap.rb | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/net/imap.rb b/lib/net/imap.rb index fed9bd8b..d5bf1cbd 100644 --- a/lib/net/imap.rb +++ b/lib/net/imap.rb @@ -1929,6 +1929,9 @@ def uid_expunge(uid_set) end end + # :call-seq: + # search(criteria, charset = nil) -> result + # # Sends a {SEARCH command [IMAP4rev1 §6.4.4]}[https://www.rfc-editor.org/rfc/rfc3501#section-6.4.4] # to search the mailbox for messages that match the given searching # criteria, and returns message sequence numbers. +keys+ can either be a @@ -1996,10 +1999,13 @@ def uid_expunge(uid_set) # result = imap.search(["SUBJECT", "hi there", "not", "new") # #=> Net::IMAP::SearchResult[1, 6, 7, 8, modseq: 5594] # result.modseq # => 5594 - def search(keys, charset = nil) - return search_internal("SEARCH", keys, charset) + def search(...) + search_internal("SEARCH", ...) end + # :call-seq: + # uid_search(criteria, charset = nil) -> result + # # Sends a {UID SEARCH command [IMAP4rev1 §6.4.8]}[https://www.rfc-editor.org/rfc/rfc3501#section-6.4.8] # to search the mailbox for messages that match the given searching # criteria, and returns unique identifiers (UIDs). @@ -2008,7 +2014,7 @@ def search(keys, charset = nil) # backward compatibility) but adds SearchResult#modseq when the +CONDSTORE+ # capability has been enabled. # - # See #search for documentation of search criteria. + # See #search for documentation of parameters. def uid_search(keys, charset = nil) return search_internal("UID SEARCH", keys, charset) end @@ -2939,7 +2945,7 @@ def enforce_logindisabled? end end - def search_internal(cmd, keys, charset) + def search_internal(cmd, keys, charset = nil) keys = normalize_searching_criteria(keys) args = charset ? ["CHARSET", charset, *keys] : keys synchronize do