[CalendarServer-changes] [8838] CalendarServer/trunk/twistedcaldav/scheduling

source_changes at macosforge.org source_changes at macosforge.org
Sat Mar 10 14:08:06 PST 2012


Revision: 8838
          http://trac.macosforge.org/projects/calendarserver/changeset/8838
Author:   cdaboo at apple.com
Date:     2012-03-10 14:08:06 -0800 (Sat, 10 Mar 2012)
Log Message:
-----------
Fix issue with expansion of RRULE with a cancel of a new instance at the same time.

Modified Paths:
--------------
    CalendarServer/trunk/twistedcaldav/scheduling/implicit.py
    CalendarServer/trunk/twistedcaldav/scheduling/itip.py
    CalendarServer/trunk/twistedcaldav/scheduling/test/test_itip.py

Modified: CalendarServer/trunk/twistedcaldav/scheduling/implicit.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/scheduling/implicit.py	2012-03-10 22:07:20 UTC (rev 8837)
+++ CalendarServer/trunk/twistedcaldav/scheduling/implicit.py	2012-03-10 22:08:06 UTC (rev 8838)
@@ -854,17 +854,17 @@
                 itipmsg = iTipGenerator.generateCancel(self.oldcalendar, (attendee,), rids)
 
             # Send scheduling message
+            if itipmsg:
+                # This is a local CALDAV scheduling operation.
+                scheduler = self.makeScheduler()
+        
+                # Do the PUT processing
+                log.info("Implicit CANCEL - organizer: '%s' to attendee: '%s', UID: '%s', RIDs: '%s'" % (self.organizer, attendee, self.uid, rids))
+                response = (yield scheduler.doSchedulingViaPUT(self.originator, (attendee,), itipmsg, self.internal_request))
+                self.handleSchedulingResponse(response, True)
+                
+                count += 1
             
-            # This is a local CALDAV scheduling operation.
-            scheduler = self.makeScheduler()
-    
-            # Do the PUT processing
-            log.info("Implicit CANCEL - organizer: '%s' to attendee: '%s', UID: '%s', RIDs: '%s'" % (self.organizer, attendee, self.uid, rids))
-            response = (yield scheduler.doSchedulingViaPUT(self.originator, (attendee,), itipmsg, self.internal_request))
-            self.handleSchedulingResponse(response, True)
-            
-            count += 1
-            
         returnValue(count)
             
     @inlineCallbacks

Modified: CalendarServer/trunk/twistedcaldav/scheduling/itip.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/scheduling/itip.py	2012-03-10 22:07:20 UTC (rev 8837)
+++ CalendarServer/trunk/twistedcaldav/scheduling/itip.py	2012-03-10 22:08:06 UTC (rev 8838)
@@ -613,6 +613,7 @@
             instances = (None,)
 
         tzids = set()
+        added = False
         for instance_rid in instances:
             
             # Create a new component matching the type of the original
@@ -621,11 +622,16 @@
             # Use the master component when the instance is None
             if not instance_rid:
                 instance = original.masterComponent()
+                assert instance is not None, "Need a master component"
             else:
                 instance = original.overriddenComponent(instance_rid)
                 if instance is None:
                     instance = original.deriveInstance(instance_rid)
-            assert instance is not None, "Need a master component"
+                    
+                # If the instance to be cancelled did not exist in the original, then
+                # do nothing
+                if instance is None:
+                    continue
 
             # Add some required properties extracted from the original
             comp.addProperty(Property("DTSTAMP", instance.propertyValue("DTSTAMP")))
@@ -662,19 +668,23 @@
             tzids.update(comp.timezoneIDs())
 
             itip.addComponent(comp)
-            
-        # Now include any referenced tzids
-        for comp in original.subcomponents():
-            if comp.name() == "VTIMEZONE":
-                tzid = comp.propertyValue("TZID")
-                if tzid in tzids:
-                    itip.addComponent(comp)
+            added = True
+        
+        if added:
+            # Now include any referenced tzids
+            for comp in original.subcomponents():
+                if comp.name() == "VTIMEZONE":
+                    tzid = comp.propertyValue("TZID")
+                    if tzid in tzids:
+                        itip.addComponent(comp)
+    
+            # Strip out unwanted bits
+            iTipGenerator.prepareSchedulingMessage(itip)
+    
+            return itip
+        else:
+            return None
 
-        # Strip out unwanted bits
-        iTipGenerator.prepareSchedulingMessage(itip)
-
-        return itip
-
     @staticmethod
     def generateAttendeeRequest(original, attendees, filter_rids):
         """

Modified: CalendarServer/trunk/twistedcaldav/scheduling/test/test_itip.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/scheduling/test/test_itip.py	2012-03-10 22:07:20 UTC (rev 8837)
+++ CalendarServer/trunk/twistedcaldav/scheduling/test/test_itip.py	2012-03-10 22:08:06 UTC (rev 8838)
@@ -1894,12 +1894,33 @@
                 ("mailto:user2 at example.com",),
                 (None, ),
             ),
+
+            # Recurring component - cancel non-existent instance
+            (
+                """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890-4
+DTSTART:20071114T000000Z
+ATTENDEE:mailto:user2 at example.com
+ORGANIZER:mailto:user1 at example.com
+RRULE:FREQ=DAILY;COUNT=10
+SEQUENCE:1
+END:VEVENT
+END:VCALENDAR
+""",
+                "",
+                ("mailto:user2 at example.com",),
+                (PyCalendarDateTime(2008, 12, 14, 0, 0, 0, tzid=PyCalendarTimezone(utc=True)), ),
+            ),
+
         )
         
         for original, filtered, attendees, instances in data:
             component = Component.fromString(original)
             itipped = iTipGenerator.generateCancel(component, attendees, instances)
-            itipped = str(itipped).replace("\r", "")
+            itipped = str(itipped).replace("\r", "") if itipped else ""
             itipped = "".join([line for line in itipped.splitlines(True) if not line.startswith("DTSTAMP:")])
             self.assertEqual(filtered, itipped)
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20120310/9f6d0c77/attachment.html>


More information about the calendarserver-changes mailing list