[CalendarServer-changes] [14953] CalendarServer/trunk/txdav/caldav/datastore
source_changes at macosforge.org
source_changes at macosforge.org
Wed Jul 8 11:41:27 PDT 2015
Revision: 14953
http://trac.calendarserver.org//changeset/14953
Author: sagen at apple.com
Date: 2015-07-08 11:41:27 -0700 (Wed, 08 Jul 2015)
Log Message:
-----------
Verify restoration of private comments are reported as a change to the client
Modified Paths:
--------------
CalendarServer/trunk/txdav/caldav/datastore/sql.py
CalendarServer/trunk/txdav/caldav/datastore/test/test_sql.py
Modified: CalendarServer/trunk/txdav/caldav/datastore/sql.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/sql.py 2015-07-08 17:25:29 UTC (rev 14952)
+++ CalendarServer/trunk/txdav/caldav/datastore/sql.py 2015-07-08 18:41:27 UTC (rev 14953)
@@ -3129,6 +3129,8 @@
comment (which will trigger scheduling with the organizer to remove the comment on the organizer's
side).
"""
+ changed = False
+
if config.Scheduling.CalDAV.get("EnablePrivateComments", True):
old_has_private_comments = not inserting and self.hasPrivateComment
new_has_private_comments = component.hasPropertyInAnyComponent((
@@ -3142,6 +3144,7 @@
component.transferProperties(old_calendar, (
"X-CALENDARSERVER-ATTENDEE-COMMENT",
))
+ changed = True
self.hasPrivateComment = new_has_private_comments
@@ -3152,7 +3155,9 @@
if component.hasDuplicatePrivateComments(doFix=config.RemoveDuplicatePrivateComments) and internal_state == ComponentUpdateState.NORMAL:
raise DuplicatePrivateCommentsError("Duplicate X-CALENDARSERVER-ATTENDEE-COMMENT properties present.")
+ returnValue(changed)
+
@inlineCallbacks
def replaceMissingToDoProperties(self, calendar, inserting, internal_state):
"""
@@ -3778,7 +3783,9 @@
yield self._lockAndCheckUID(component, inserting, internal_state)
# Preserve private comments
- yield self.preservePrivateComments(component, inserting, internal_state)
+ changed = yield self.preservePrivateComments(component, inserting, internal_state)
+ if changed:
+ self._componentChanged = True
# Fix broken VTODOs
yield self.replaceMissingToDoProperties(component, inserting, internal_state)
Modified: CalendarServer/trunk/txdav/caldav/datastore/test/test_sql.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/test/test_sql.py 2015-07-08 17:25:29 UTC (rev 14952)
+++ CalendarServer/trunk/txdav/caldav/datastore/test/test_sql.py 2015-07-08 18:41:27 UTC (rev 14953)
@@ -2550,7 +2550,7 @@
-class SchedulingTests(CommonCommonTests, unittest.TestCase):
+class SchedulingTests(CommonCommonTests, DateTimeSubstitutionsMixin, unittest.TestCase):
"""
CalendarObject splitting tests
"""
@@ -2559,6 +2559,7 @@
def setUp(self):
yield super(SchedulingTests, self).setUp()
yield self.buildStoreAndDirectory()
+ self.setupDateTimeValues()
# Make sure homes are provisioned
txn = self.transactionUnderTest()
@@ -3226,7 +3227,69 @@
yield self.commit()
+ @inlineCallbacks
+ def test_setComponent_changed_preservePrivateComments(self):
+ """
+ Verify we let the client know we preserved private comments
+ """
+ dataWith = """BEGIN:VCALENDAR
+VERSION:2.0
+CALSCALE:GREGORIAN
+PRODID:-//Apple Inc.//Mac OS X 10.9.1//EN
+BEGIN:VEVENT
+UID:561F5DBB-3F38-4B3A-986F-DD05CBAF554F
+DTSTART:%(now_fwd30)s
+DURATION:PT1H
+CREATED:%(now)s
+DTSTAMP:%(now)s
+SEQUENCE:1
+SUMMARY:testing
+TRANSP:OPAQUE
+X-CALENDARSERVER-ATTENDEE-COMMENT;X-CALENDARSERVER-ATTENDEE-REF="urn:uuid:user01";X-CALENDARSERVER-DTSTAMP=%(now)s:Message1
+END:VEVENT
+END:VCALENDAR
+""".replace("\n", "\r\n")
+
+ dataWithout = """BEGIN:VCALENDAR
+VERSION:2.0
+CALSCALE:GREGORIAN
+PRODID:-//Apple Inc.//Mac OS X 10.9.1//EN
+BEGIN:VEVENT
+UID:561F5DBB-3F38-4B3A-986F-DD05CBAF554F
+DTSTART:%(now_fwd30)s
+DURATION:PT1H
+CREATED:%(now)s
+DTSTAMP:%(now)s
+SEQUENCE:1
+SUMMARY:testing
+TRANSP:OPAQUE
+END:VEVENT
+END:VCALENDAR
+""".replace("\n", "\r\n")
+
+ calendar = yield self.calendarUnderTest(name="calendar", home="user01")
+ yield calendar.createCalendarObjectWithName(
+ "comments.ics",
+ Component.fromString(dataWith % self.dtsubs)
+ )
+
+ yield self.commit()
+
+ cobj = yield self.calendarObjectUnderTest(
+ name="comments.ics",
+ calendar_name="calendar",
+ home="user01"
+ )
+
+ comp = Component.fromString(dataWithout % self.dtsubs)
+ yield cobj.setComponent(comp)
+ comp = yield cobj.componentForUser()
+ self.assertTrue(cobj._componentChanged)
+
+ yield self.commit()
+
+
@inlineCallbacks
def test_setComponent_externalPrincipal(self):
"""
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20150708/2dd351d0/attachment-0001.html>
More information about the calendarserver-changes
mailing list