@@ -511,6 +511,8 @@ module Net
511
511
# search criterion, and adds SearchResult#modseq to the search response.
512
512
# - Updates #thread and #uid_thread with the +MODSEQ+ search criterion
513
513
# <em>(but thread responses are unchanged)</em>.
514
+ # - Updates #fetch and #uid_fetch with the +changedsince+ modifier and
515
+ # +MODSEQ+ FetchData attribute.
514
516
#
515
517
# ==== RFC8438: <tt>STATUS=SIZE</tt>
516
518
# - Updates #status with the +SIZE+ status attribute.
@@ -1986,6 +1988,9 @@ def uid_search(keys, charset = nil)
1986
1988
return search_internal ( "UID SEARCH" , keys , charset )
1987
1989
end
1988
1990
1991
+ # :call-seq:
1992
+ # fetch(set, attr, changedsince: nil) -> array of FetchData
1993
+ #
1989
1994
# Sends a {FETCH command [IMAP4rev1 §6.4.5]}[https://www.rfc-editor.org/rfc/rfc3501#section-6.4.5]
1990
1995
# to retrieve data associated with a message in the mailbox.
1991
1996
#
@@ -2001,6 +2006,9 @@ def uid_search(keys, charset = nil)
2001
2006
# +attr+ is a list of attributes to fetch; see the documentation
2002
2007
# for FetchData for a list of valid attributes.
2003
2008
#
2009
+ # +changedsince+ is an optional integer mod-sequence. It limits results to
2010
+ # messages with a mod-sequence greater than +changedsince+.
2011
+ #
2004
2012
# The return value is an array of FetchData.
2005
2013
#
2006
2014
# Related: #uid_search, FetchData
@@ -2022,10 +2030,23 @@ def uid_search(keys, charset = nil)
2022
2030
# #=> "12-Oct-2000 22:40:59 +0900"
2023
2031
# p data.attr["UID"]
2024
2032
# #=> 98
2025
- def fetch ( set , attr , mod = nil )
2026
- return fetch_internal ( "FETCH" , set , attr , mod )
2033
+ #
2034
+ # ===== Capabilities
2035
+ #
2036
+ # Many extensions define new message +attr+ names. See FetchData for a list
2037
+ # of supported extension fields.
2038
+ #
2039
+ # The server's capabilities must include +CONDSTORE+
2040
+ # {[RFC7162]}[https://tools.ietf.org/html/rfc7162] in order to use the
2041
+ # +changedsince+ argument. Using +changedsince+ implicitly enables the
2042
+ # +CONDSTORE+ extension.
2043
+ def fetch ( set , attr , mod = nil , changedsince : nil )
2044
+ fetch_internal ( "FETCH" , set , attr , mod , changedsince : changedsince )
2027
2045
end
2028
2046
2047
+ # :call-seq:
2048
+ # uid_fetch(set, attr, changedsince: nil) -> array of FetchData
2049
+ #
2029
2050
# Sends a {UID FETCH command [IMAP4rev1 §6.4.8]}[https://www.rfc-editor.org/rfc/rfc3501#section-6.4.8]
2030
2051
# to retrieve data associated with a message in the mailbox.
2031
2052
#
@@ -2038,8 +2059,11 @@ def fetch(set, attr, mod = nil)
2038
2059
# whether a +UID+ was specified as a message data item to the +FETCH+.
2039
2060
#
2040
2061
# Related: #fetch, FetchData
2041
- def uid_fetch ( set , attr , mod = nil )
2042
- return fetch_internal ( "UID FETCH" , set , attr , mod )
2062
+ #
2063
+ # ===== Capabilities
2064
+ # Same as #fetch.
2065
+ def uid_fetch ( set , attr , mod = nil , changedsince : nil )
2066
+ fetch_internal ( "UID FETCH" , set , attr , mod , changedsince : changedsince )
2043
2067
end
2044
2068
2045
2069
# Sends a {STORE command [IMAP4rev1 §6.4.6]}[https://www.rfc-editor.org/rfc/rfc3501#section-6.4.6]
@@ -2760,7 +2784,11 @@ def search_internal(cmd, keys, charset)
2760
2784
end
2761
2785
end
2762
2786
2763
- def fetch_internal ( cmd , set , attr , mod = nil )
2787
+ def fetch_internal ( cmd , set , attr , mod = nil , changedsince : nil )
2788
+ if changedsince
2789
+ mod ||= [ ]
2790
+ mod << "CHANGEDSINCE" << Integer ( changedsince )
2791
+ end
2764
2792
case attr
2765
2793
when String then
2766
2794
attr = RawData . new ( attr )
0 commit comments