async-caldav 1.2.4 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/async/caldav/client/addressbook.rb +21 -9
- data/lib/async/caldav/client/calendar.rb +39 -15
- data/lib/async/caldav/client.rb +423 -371
- data/lib/async/caldav/forward_auth.rb +61 -54
- data/lib/async/caldav/handlers/delete.rb +28 -30
- data/lib/async/caldav/handlers/get.rb +45 -47
- data/lib/async/caldav/handlers/head.rb +16 -18
- data/lib/async/caldav/handlers/mkcol.rb +64 -68
- data/lib/async/caldav/handlers/move.rb +99 -90
- data/lib/async/caldav/handlers/options.rb +15 -17
- data/lib/async/caldav/handlers/propfind.rb +140 -139
- data/lib/async/caldav/handlers/proppatch.rb +95 -90
- data/lib/async/caldav/handlers/put.rb +139 -119
- data/lib/async/caldav/handlers/report.rb +192 -161
- data/lib/async/caldav/server.rb +1029 -994
- data/lib/async/caldav/storage/filesystem.rb +247 -220
- data/lib/async/caldav/storage/mock.rb +254 -246
- data/lib/async/caldav/version.rb +1 -1
- metadata +19 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 971fb69146a93d8657e1c629d81ea95faf49749d0cecffaef4b05338d7cf44b2
|
|
4
|
+
data.tar.gz: bcfd995444a48137f9de0d7d1b1fa9e60f6a161bb8b84b0da8a30368d67ce1e1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b7b37b620996b985bbc5052dcfe3e9124bc0377dc924ccdae9e638de8cdda943eae064a39246294bb0e8e139daa410d68531057cf39dab0cc75482efeb4605a8
|
|
7
|
+
data.tar.gz: e023fd085b489d0d45ee3c8cdc3a5d8bfa4c068ee5a6129381f51a6994fdb980f4b4d0d935be01383ab99518fe56207759189724b9b4c48dc019ed0d86bf6162
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require "bundler/setup"
|
|
4
|
-
require "scampi"
|
|
5
3
|
require "builder"
|
|
6
4
|
|
|
7
5
|
module Async
|
|
@@ -21,20 +19,28 @@ module Async
|
|
|
21
19
|
x.instruct! :xml, version: "1.0", encoding: "UTF-8"
|
|
22
20
|
x.tag!("cr:addressbook-query", "xmlns:d" => "DAV:", "xmlns:cr" => "urn:ietf:params:xml:ns:carddav") do
|
|
23
21
|
x.tag!("d:prop") { x.tag!("d:getetag"); x.tag!("cr:address-data") }
|
|
24
|
-
|
|
22
|
+
if filter
|
|
23
|
+
x << filter
|
|
24
|
+
end
|
|
25
25
|
end
|
|
26
26
|
body = x.target!
|
|
27
27
|
|
|
28
28
|
status, _, resp_body = @client.request('REPORT', @path, body: body, headers: { 'Content-Type' => 'text/xml' })
|
|
29
|
-
|
|
29
|
+
unless status == 207
|
|
30
|
+
raise Error, "REPORT failed: #{status}"
|
|
31
|
+
end
|
|
30
32
|
|
|
31
33
|
@client.parse_multistatus_items(resp_body, data_tag: 'address-data')
|
|
32
34
|
end
|
|
33
35
|
|
|
34
36
|
def put_contact(filename, body, if_match: nil, if_none_match: nil)
|
|
35
37
|
headers = { 'Content-Type' => 'text/vcard' }
|
|
36
|
-
|
|
37
|
-
|
|
38
|
+
if if_match
|
|
39
|
+
headers['If-Match'] = if_match
|
|
40
|
+
end
|
|
41
|
+
if if_none_match
|
|
42
|
+
headers['If-None-Match'] = if_none_match
|
|
43
|
+
end
|
|
38
44
|
|
|
39
45
|
path = "#{@path}#{filename}"
|
|
40
46
|
status, resp_headers, = @client.request('PUT', path, body: body, headers: headers)
|
|
@@ -92,15 +98,21 @@ module Async
|
|
|
92
98
|
x.tag!("d:propertyupdate", "xmlns:d" => "DAV:") do
|
|
93
99
|
x.tag!("d:set") do
|
|
94
100
|
x.tag!("d:prop") do
|
|
95
|
-
|
|
101
|
+
if displayname
|
|
102
|
+
x.tag!("d:displayname", displayname)
|
|
103
|
+
end
|
|
96
104
|
end
|
|
97
105
|
end
|
|
98
106
|
end
|
|
99
107
|
|
|
100
108
|
status, = @client.request('PROPPATCH', @path, body: x.target!, headers: { 'Content-Type' => 'text/xml' })
|
|
101
|
-
|
|
109
|
+
unless status == 207
|
|
110
|
+
raise Error, "PROPPATCH failed: #{status}"
|
|
111
|
+
end
|
|
102
112
|
|
|
103
|
-
|
|
113
|
+
if displayname
|
|
114
|
+
@displayname = displayname
|
|
115
|
+
end
|
|
104
116
|
self
|
|
105
117
|
end
|
|
106
118
|
end
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require "bundler/setup"
|
|
4
|
-
require "scampi"
|
|
5
3
|
require "builder"
|
|
6
4
|
|
|
7
5
|
module Async
|
|
@@ -24,20 +22,28 @@ module Async
|
|
|
24
22
|
x.instruct! :xml, version: "1.0", encoding: "UTF-8"
|
|
25
23
|
x.tag!("c:calendar-query", "xmlns:d" => "DAV:", "xmlns:c" => "urn:ietf:params:xml:ns:caldav") do
|
|
26
24
|
x.tag!("d:prop") { x.tag!("d:getetag"); x.tag!("c:calendar-data") }
|
|
27
|
-
|
|
25
|
+
if filter
|
|
26
|
+
x << filter
|
|
27
|
+
end
|
|
28
28
|
end
|
|
29
29
|
body = x.target!
|
|
30
30
|
|
|
31
31
|
status, _, resp_body = @client.request('REPORT', @path, body: body, headers: { 'Content-Type' => 'text/xml' })
|
|
32
|
-
|
|
32
|
+
unless status == 207
|
|
33
|
+
raise Error, "REPORT failed: #{status}"
|
|
34
|
+
end
|
|
33
35
|
|
|
34
36
|
@client.parse_multistatus_items(resp_body, data_tag: 'calendar-data')
|
|
35
37
|
end
|
|
36
38
|
|
|
37
39
|
def put_event(filename, body, if_match: nil, if_none_match: nil)
|
|
38
40
|
headers = { 'Content-Type' => 'text/calendar' }
|
|
39
|
-
|
|
40
|
-
|
|
41
|
+
if if_match
|
|
42
|
+
headers['If-Match'] = if_match
|
|
43
|
+
end
|
|
44
|
+
if if_none_match
|
|
45
|
+
headers['If-None-Match'] = if_none_match
|
|
46
|
+
end
|
|
41
47
|
|
|
42
48
|
path = "#{@path}#{filename}"
|
|
43
49
|
status, resp_headers, = @client.request('PUT', path, body: body, headers: headers)
|
|
@@ -91,7 +97,9 @@ module Async
|
|
|
91
97
|
|
|
92
98
|
def propfind
|
|
93
99
|
status, _, body = @client.request('PROPFIND', @path, headers: { 'Depth' => '0' })
|
|
94
|
-
|
|
100
|
+
unless status == 207
|
|
101
|
+
raise Error, "PROPFIND failed: #{status}"
|
|
102
|
+
end
|
|
95
103
|
@client.parse_collection_props(body)
|
|
96
104
|
end
|
|
97
105
|
|
|
@@ -101,19 +109,33 @@ module Async
|
|
|
101
109
|
x.tag!("d:propertyupdate", "xmlns:d" => "DAV:", "xmlns:c" => "urn:ietf:params:xml:ns:caldav", "xmlns:x" => "http://apple.com/ns/ical/") do
|
|
102
110
|
x.tag!("d:set") do
|
|
103
111
|
x.tag!("d:prop") do
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
112
|
+
if displayname
|
|
113
|
+
x.tag!("d:displayname", displayname)
|
|
114
|
+
end
|
|
115
|
+
if description
|
|
116
|
+
x.tag!("c:calendar-description", description)
|
|
117
|
+
end
|
|
118
|
+
if color
|
|
119
|
+
x.tag!("x:calendar-color", color)
|
|
120
|
+
end
|
|
107
121
|
end
|
|
108
122
|
end
|
|
109
123
|
end
|
|
110
124
|
|
|
111
125
|
status, = @client.request('PROPPATCH', @path, body: x.target!, headers: { 'Content-Type' => 'text/xml' })
|
|
112
|
-
|
|
126
|
+
unless status == 207
|
|
127
|
+
raise Error, "PROPPATCH failed: #{status}"
|
|
128
|
+
end
|
|
113
129
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
130
|
+
if displayname
|
|
131
|
+
@displayname = displayname
|
|
132
|
+
end
|
|
133
|
+
if description
|
|
134
|
+
@description = description
|
|
135
|
+
end
|
|
136
|
+
if color
|
|
137
|
+
@color = color
|
|
138
|
+
end
|
|
117
139
|
self
|
|
118
140
|
end
|
|
119
141
|
|
|
@@ -135,7 +157,9 @@ module Async
|
|
|
135
157
|
if status == 403
|
|
136
158
|
raise InvalidSyncToken, "Invalid sync token"
|
|
137
159
|
end
|
|
138
|
-
|
|
160
|
+
unless status == 207
|
|
161
|
+
raise Error, "REPORT failed: #{status}"
|
|
162
|
+
end
|
|
139
163
|
|
|
140
164
|
new_token = resp_body.match(/<[^>]*sync-token[^>]*>([^<]+)</)[1] rescue nil
|
|
141
165
|
items = @client.parse_sync_items(resp_body)
|