Drop address-data from sync-collection responses
Minimization round 5: the warm-sync ask is getetag-only, so the
answer returns just that; a changed etag sends the client back through
multiget, which keeps address-data. Saves the full vCard from every
hourly poll.
Assisted-by: GLM 5.2 via pi
diff --git a/lib/pro_tacts/web.rb b/lib/pro_tacts/web.rb
index c202d0c..02da5fa 100644
--- a/lib/pro_tacts/web.rb
+++ b/lib/pro_tacts/web.rb
@@ -221,19 +221,30 @@ module ProTacts
end
r.report do
+ body = request.body.read
+ request.body.rewind
+
response["Content-Type"] = "text/xml"
response.status = 207
contact_etag = %("a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2")
- vcard = <<~VCARD.chomp
- BEGIN:VCARD
- VERSION:3.0
- PRODID:-//Apple Inc.//macOS 14.6.1//EN
- N:Contact;Test;;;
- FN:Test Contact
- REV:2026-01-14T00:00:00Z
- UID:AB12C345-6789-0DEF-1234-567890ABCDEF
- END:VCARD
- VCARD
+
+ if body.include?("sync-collection")
+ # The warm-sync ask is etag-only; a changed etag sends the
+ # client back through multiget, so no address-data here.
+ card_data = ""
+ else
+ vcard = <<~VCARD.chomp
+ BEGIN:VCARD
+ VERSION:3.0
+ PRODID:-//Apple Inc.//macOS 14.6.1//EN
+ N:Contact;Test;;;
+ FN:Test Contact
+ REV:2026-01-14T00:00:00Z
+ UID:AB12C345-6789-0DEF-1234-567890ABCDEF
+ END:VCARD
+ VCARD
+ card_data = "<card:address-data>#{vcard}</card:address-data>"
+ end
<<~XML
<?xml version="1.0" encoding="UTF-8"?>
@@ -243,7 +254,7 @@ module ProTacts
<d:propstat>
<d:prop>
<d:getetag>#{contact_etag}</d:getetag>
- <card:address-data>#{vcard}</card:address-data>
+ #{card_data unless card_data.empty?}
</d:prop>
<d:status>HTTP/1.1 200 OK</d:status>
</d:propstat>
diff --git a/test/fixtures/macos-exchange/08-report-sync-collection/response b/test/fixtures/macos-exchange/08-report-sync-collection/response
index be34f5b..aa8852a 100644
--- a/test/fixtures/macos-exchange/08-report-sync-collection/response
+++ b/test/fixtures/macos-exchange/08-report-sync-collection/response
@@ -8,14 +8,7 @@ Content-Type: text/xml
<d:propstat>
<d:prop>
<d:getetag>"a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2"</d:getetag>
- <card:address-data>BEGIN:VCARD
-VERSION:3.0
-PRODID:-//Apple Inc.//macOS 14.6.1//EN
-N:Contact;Test;;;
-FN:Test Contact
-REV:2026-01-14T00:00:00Z
-UID:AB12C345-6789-0DEF-1234-567890ABCDEF
-END:VCARD</card:address-data>
+
</d:prop>
<d:status>HTTP/1.1 200 OK</d:status>
</d:propstat>