@@ -513,6 +513,8 @@ module Net
513
513
# <em>(but thread responses are unchanged)</em>.
514
514
# - Updates #fetch and #uid_fetch with the +changedsince+ modifier and
515
515
# +MODSEQ+ FetchData attribute.
516
+ # - Updates #store and #uid_store with the +unchangedsince+ modifier and adds
517
+ # the +MODIFIED+ ResponseCode to the tagged response.
516
518
#
517
519
# ==== RFC8438: <tt>STATUS=SIZE</tt>
518
520
# - Updates #status with the +SIZE+ status attribute.
@@ -2066,13 +2068,29 @@ def uid_fetch(set, attr, mod = nil, changedsince: nil)
2066
2068
fetch_internal ( "UID FETCH" , set , attr , mod , changedsince : changedsince )
2067
2069
end
2068
2070
2071
+ # :call-seq:
2072
+ # store(set, attr, value, unchangedsince: nil) -> array of FetchData
2073
+ #
2069
2074
# Sends a {STORE command [IMAP4rev1 §6.4.6]}[https://www.rfc-editor.org/rfc/rfc3501#section-6.4.6]
2070
2075
# to alter data associated with messages in the mailbox, in particular their
2071
- # flags. The +set+ parameter is a number, an array of numbers, or a Range
2072
- # object. Each number is a message sequence number. +attr+ is the name of a
2073
- # data item to store: <tt>"FLAGS"</tt> will replace the message's flag list
2074
- # with the provided one, <tt>"+FLAGS"</tt> will add the provided flags, and
2075
- # <tt>"-FLAGS"</tt> will remove them. +flags+ is a list of flags.
2076
+ # flags.
2077
+ #
2078
+ # +set+ is a number, an array of numbers, or a Range object. Each number is
2079
+ # a message sequence number.
2080
+ #
2081
+ # +attr+ is the name of a data item to store. The semantics of +value+
2082
+ # varies based on +attr+:
2083
+ # * When +attr+ is <tt>"FLAGS"</tt>, the flags in +value+ replace the
2084
+ # message's flag list.
2085
+ # * When +attr+ is <tt>"+FLAGS"</tt>, the flags in +value+ are added to
2086
+ # the flags for the message.
2087
+ # * When +attr+ is <tt>"-FLAGS"</tt>, the flags in +value+ are removed
2088
+ # from the message.
2089
+ #
2090
+ # +unchangedsince+ is an optional integer mod-sequence. It prohibits any
2091
+ # changes to messages with +mod-sequence+ greater than the specified
2092
+ # +unchangedsince+ value. A SequenceSet of any messages that fail this
2093
+ # check will be returned in a +MODIFIED+ ResponseCode.
2076
2094
#
2077
2095
# The return value is an array of FetchData.
2078
2096
#
@@ -2081,13 +2099,25 @@ def uid_fetch(set, attr, mod = nil, changedsince: nil)
2081
2099
# ===== For example:
2082
2100
#
2083
2101
# p imap.store(6..8, "+FLAGS", [:Deleted])
2084
- # #=> [#<Net::IMAP::FetchData seqno=6, attr={"FLAGS"=>[:Seen, :Deleted]}>, \\
2085
- # #<Net::IMAP::FetchData seqno=7, attr={"FLAGS"=>[:Seen, :Deleted]}>, \\
2102
+ # #=> [#<Net::IMAP::FetchData seqno=6, attr={"FLAGS"=>[:Seen, :Deleted]}>,
2103
+ # #<Net::IMAP::FetchData seqno=7, attr={"FLAGS"=>[:Seen, :Deleted]}>,
2086
2104
# #<Net::IMAP::FetchData seqno=8, attr={"FLAGS"=>[:Seen, :Deleted]}>]
2087
- def store ( set , attr , flags )
2088
- return store_internal ( "STORE" , set , attr , flags )
2105
+ #
2106
+ # ===== Capabilities
2107
+ #
2108
+ # Extensions may define new data items to be used with #store.
2109
+ #
2110
+ # The server's capabilities must include +CONDSTORE+
2111
+ # {[RFC7162]}[https://tools.ietf.org/html/rfc7162] in order to use the
2112
+ # +unchangedsince+ argument. Using +unchangedsince+ implicitly enables the
2113
+ # +CONDSTORE+ extension.
2114
+ def store ( set , attr , flags , unchangedsince : nil )
2115
+ store_internal ( "STORE" , set , attr , flags , unchangedsince : unchangedsince )
2089
2116
end
2090
2117
2118
+ # :call-seq:
2119
+ # uid_store(set, attr, value, unchangedsince: nil) -> array of FetchData
2120
+ #
2091
2121
# Sends a {UID STORE command [IMAP4rev1 §6.4.8]}[https://www.rfc-editor.org/rfc/rfc3501#section-6.4.8]
2092
2122
# to alter data associated with messages in the mailbox, in particular their
2093
2123
# flags.
@@ -2096,8 +2126,11 @@ def store(set, attr, flags)
2096
2126
# message sequence numbers.
2097
2127
#
2098
2128
# Related: #store
2099
- def uid_store ( set , attr , flags )
2100
- return store_internal ( "UID STORE" , set , attr , flags )
2129
+ #
2130
+ # ===== Capabilities
2131
+ # Same as #store.
2132
+ def uid_store ( set , attr , flags , unchangedsince : nil )
2133
+ store_internal ( "UID STORE" , set , attr , flags , unchangedsince : unchangedsince )
2101
2134
end
2102
2135
2103
2136
# Sends a {COPY command [IMAP4rev1 §6.4.7]}[https://www.rfc-editor.org/rfc/rfc3501#section-6.4.7]
@@ -2809,13 +2842,14 @@ def fetch_internal(cmd, set, attr, mod = nil, changedsince: nil)
2809
2842
end
2810
2843
end
2811
2844
2812
- def store_internal ( cmd , set , attr , flags )
2813
- if attr . instance_of? ( String )
2814
- attr = RawData . new ( attr )
2815
- end
2845
+ def store_internal ( cmd , set , attr , flags , unchangedsince : nil )
2846
+ attr = RawData . new ( attr ) if attr . instance_of? ( String )
2847
+ args = [ MessageSet . new ( set ) ]
2848
+ args << [ "UNCHANGEDSINCE" , Integer ( unchangedsince ) ] if unchangedsince
2849
+ args << attr << flags
2816
2850
synchronize do
2817
2851
clear_responses ( "FETCH" )
2818
- send_command ( cmd , MessageSet . new ( set ) , attr , flags )
2852
+ send_command ( cmd , * args )
2819
2853
clear_responses ( "FETCH" )
2820
2854
end
2821
2855
end
0 commit comments