[CalendarServer-changes] [14653] CalendarServer/trunk/txdav

source_changes at macosforge.org source_changes at macosforge.org
Thu Apr 2 14:43:08 PDT 2015


Revision: 14653
          http://trac.calendarserver.org//changeset/14653
Author:   sagen at apple.com
Date:     2015-04-02 14:43:08 -0700 (Thu, 02 Apr 2015)
Log Message:
-----------
If an attendee has a trashed event with the same uid as a new invite, the trashed copy will be removed

Modified Paths:
--------------
    CalendarServer/trunk/txdav/caldav/datastore/scheduling/processing.py
    CalendarServer/trunk/txdav/common/datastore/test/test_trash.py

Modified: CalendarServer/trunk/txdav/caldav/datastore/scheduling/processing.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/scheduling/processing.py	2015-04-02 20:50:41 UTC (rev 14652)
+++ CalendarServer/trunk/txdav/caldav/datastore/scheduling/processing.py	2015-04-02 21:43:08 UTC (rev 14653)
@@ -364,7 +364,15 @@
                 # is local to the server - then allow the change
                 if not (existing_organizer == "" and self.originator.hosted()):
                     log.debug("ImplicitProcessing - originator '%s' to recipient '%s' ignoring UID: '%s' - organizer has no copy" % (self.originator.cuaddr, self.recipient.cuaddr, self.uid))
-                    raise ImplicitProcessorException("5.3;Organizer change not allowed")
+                    # If the recipient copy is in the trash, just remove it
+                    if (yield self.recipient_calendar_resource.isInTrash()):
+                        yield self.recipient_calendar_resource.remove(bypassTrash=True)
+                        # Reset state to make it look like a new iTIP being processed
+                        self.recipient_calendar = None
+                        self.recipient_calendar_resource = None
+                        self.new_resource = True
+                    else:
+                        raise ImplicitProcessorException("5.3;Organizer change not allowed")
 
                 # For a missing existing organizer we don't know for sure that the existing event came from the originator - it could be spoofed
                 # by the originator to have the same UID as the existing event which it would overwrite. Instead what we will do is rename and

Modified: CalendarServer/trunk/txdav/common/datastore/test/test_trash.py
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/test/test_trash.py	2015-04-02 20:50:41 UTC (rev 14652)
+++ CalendarServer/trunk/txdav/common/datastore/test/test_trash.py	2015-04-02 21:43:08 UTC (rev 14653)
@@ -1971,6 +1971,90 @@
 
 
     @inlineCallbacks
+    def test_trashDuplicateUIDDifferentOrganizer(self):
+        """
+        Verify an attendee with a trashed copy of an event with a different
+        organizer will have that copy removed.
+        """
+
+        from twistedcaldav.stdconfig import config
+        self.patch(config, "EnableTrashCollection", True)
+
+        organizer1_data = """BEGIN:VCALENDAR
+CALSCALE:GREGORIAN
+PRODID:-//Example Inc.//Example Calendar//EN
+VERSION:2.0
+BEGIN:VEVENT
+DTSTAMP:20051222T205953Z
+CREATED:20060101T150000Z
+DTSTART:20140101T100000Z
+DURATION:PT1H
+SUMMARY:event 1
+UID:duplicate
+ORGANIZER:mailto:user01 at example.com
+ATTENDEE:mailto:user01 at example.com
+ATTENDEE:mailto:user03 at example.com
+END:VEVENT
+END:VCALENDAR
+"""
+        organizer2_data = """BEGIN:VCALENDAR
+CALSCALE:GREGORIAN
+PRODID:-//Example Inc.//Example Calendar//EN
+VERSION:2.0
+BEGIN:VEVENT
+DTSTAMP:20051222T205953Z
+CREATED:20060101T150000Z
+DTSTART:20140101T100000Z
+DURATION:PT1H
+SUMMARY:event 2
+UID:duplicate
+ORGANIZER:mailto:user02 at example.com
+ATTENDEE:mailto:user02 at example.com
+ATTENDEE:mailto:user03 at example.com
+END:VEVENT
+END:VCALENDAR
+"""
+
+        # user01 invites user03
+        txn = self.store.newTransaction()
+        home1 = yield txn.calendarHomeWithUID("user01", create=True)
+        collection = yield home1.childWithName("calendar")
+        resource = yield collection.createObjectResourceWithName(
+            "test.ics",
+            Component.allFromString(organizer1_data)
+        )
+        yield txn.commit()
+        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
+
+        # user03 trashes the event
+        txn = self.store.newTransaction()
+        resource = yield self._getResource(txn, "user03", "calendar", "")
+        yield resource.remove()
+        yield txn.commit()
+        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
+
+        # user02 invites user03 using an event with the same uid
+        txn = self.store.newTransaction()
+        home2 = yield txn.calendarHomeWithUID("user02", create=True)
+        collection = yield home2.childWithName("calendar")
+        resource = yield collection.createObjectResourceWithName(
+            "test.ics",
+            Component.allFromString(organizer2_data)
+        )
+        yield txn.commit()
+        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
+
+        # user03's trash is now empty, and user03's copy is the invite from user02
+        txn = self.store.newTransaction()
+        resourceNames = yield self._getTrashNames(txn, "user03")
+        self.assertEquals(len(resourceNames), 0)
+        newData = yield self._getResourceData(txn, "user03", "calendar", "")
+        self.assertTrue("user02" in newData)
+        yield txn.commit()
+        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
+
+
+    @inlineCallbacks
     def test_tool_emptyTrashForPrincipal(self):
 
         from twistedcaldav.stdconfig import config
@@ -2061,6 +2145,9 @@
 
     @inlineCallbacks
     def test_trashedCalendars(self):
+        """
+        Verify home.calendars(onlyInTrash=) works
+        """
 
         from twistedcaldav.stdconfig import config
         self.patch(config, "EnableTrashCollection", True)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20150402/5dcf8b32/attachment.html>


More information about the calendarserver-changes mailing list