[CalendarServer-changes] [14836] CalendarServer/trunk

source_changes at macosforge.org source_changes at macosforge.org
Wed May 27 11:25:43 PDT 2015


Revision: 14836
          http://trac.calendarserver.org//changeset/14836
Author:   cdaboo at apple.com
Date:     2015-05-27 11:25:43 -0700 (Wed, 27 May 2015)
Log Message:
-----------
Don't process attendee replies for schedule-agent=client/none events or ones not listing the attendee.

Modified Paths:
--------------
    CalendarServer/trunk/calendarserver/tools/importer.py
    CalendarServer/trunk/requirements-dev.txt
    CalendarServer/trunk/txdav/caldav/datastore/scheduling/implicit.py
    CalendarServer/trunk/txdav/caldav/datastore/scheduling/itip.py
    CalendarServer/trunk/txdav/caldav/datastore/scheduling/test/test_implicit.py

Modified: CalendarServer/trunk/calendarserver/tools/importer.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/importer.py	2015-05-27 18:24:04 UTC (rev 14835)
+++ CalendarServer/trunk/calendarserver/tools/importer.py	2015-05-27 18:25:43 UTC (rev 14836)
@@ -278,14 +278,15 @@
             organizerCUA = organizerRecord.canonicalCalendarUserAddress()
             processor = ImplicitProcessor()
             newComponent = iTipGenerator.generateAttendeeReply(groupedComponent, attendeeCUA, method="X-RESTORE")
-            txn = store.newTransaction()
-            yield processor.doImplicitProcessing(
-                txn,
-                newComponent,
-                LocalCalendarUser(attendeeCUA, ownerRecord),
-                LocalCalendarUser(organizerCUA, organizerRecord)
-            )
-            yield txn.commit()
+            if newComponent is not None:
+                txn = store.newTransaction()
+                yield processor.doImplicitProcessing(
+                    txn,
+                    newComponent,
+                    LocalCalendarUser(attendeeCUA, ownerRecord),
+                    LocalCalendarUser(organizerCUA, organizerRecord)
+                )
+                yield txn.commit()
 
 
 

Modified: CalendarServer/trunk/requirements-dev.txt
===================================================================
--- CalendarServer/trunk/requirements-dev.txt	2015-05-27 18:24:04 UTC (rev 14835)
+++ CalendarServer/trunk/requirements-dev.txt	2015-05-27 18:25:43 UTC (rev 14836)
@@ -8,4 +8,4 @@
 q
 tl.eggdeps
 --editable svn+http://svn.calendarserver.org/repository/calendarserver/CalDAVClientLibrary/trunk@14811#egg=CalDAVClientLibrary
---editable svn+http://svn.calendarserver.org/repository/calendarserver/CalDAVTester/trunk@14831#egg=CalDAVTester
+--editable svn+http://svn.calendarserver.org/repository/calendarserver/CalDAVTester/trunk@14835#egg=CalDAVTester

Modified: CalendarServer/trunk/txdav/caldav/datastore/scheduling/implicit.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/scheduling/implicit.py	2015-05-27 18:24:04 UTC (rev 14835)
+++ CalendarServer/trunk/txdav/caldav/datastore/scheduling/implicit.py	2015-05-27 18:25:43 UTC (rev 14836)
@@ -17,7 +17,7 @@
 from twext.python.log import Logger
 from txweb2.dav.http import ErrorResponse
 
-from twisted.internet.defer import inlineCallbacks, returnValue
+from twisted.internet.defer import inlineCallbacks, returnValue, succeed
 from txweb2 import responsecode
 from txweb2.http import HTTPError
 
@@ -504,7 +504,6 @@
 
     @inlineCallbacks
     def sendAttendeeReply(self, txn, resource):
-
         self.txn = txn
         self.resource = resource
 
@@ -520,14 +519,21 @@
         # Get some useful information from the calendar
         yield self.extractCalendarData()
 
+        self.organizerAddress = (yield calendarUserFromCalendarUserAddress(self.organizer, self.txn))
         self.attendeeAddress = (yield calendarUserFromCalendarUserUID(self.calendar_home.uid(), self.txn))
         self.originator = self.attendee = self.attendeeAddress.record.canonicalCalendarUserAddress()
 
-        result = (yield self.scheduleWithOrganizer())
 
-        returnValue(result)
+        # Check SCHEDULE-AGENT
+        if not self.checkOrganizerScheduleAgent():
+            returnValue(False)
 
+        # result is None if this succeeds, else False
+        result = yield self.scheduleWithOrganizer()
 
+        returnValue(result != False)
+
+
     @inlineCallbacks
     def extractCalendarData(self):
 
@@ -1726,6 +1732,10 @@
             self.logItems["itip.reply"] = "reply"
 
         itipmsg = iTipGenerator.generateAttendeeReply(self.calendar, self.attendee, changedRids=changedRids)
+        if itipmsg is None:
+            # Log and ignore this situation
+            log.debug("Empty iTIP attendee reply: Attendee '{attendee}', UID: {uid}".format(attendee=self.attendee, uid=self.uid))
+            return succeed(False)
         if config.Scheduling.Options.WorkQueues.Enabled:
             # Always make it look like scheduling succeeded when queuing
             self.calendar.setParameterToValueForPropertyWithValue(
@@ -1751,6 +1761,10 @@
             self.logItems["itip.reply"] = "cancel"
 
         itipmsg = iTipGenerator.generateAttendeeReply(self.calendar, self.attendee, force_decline=True)
+        if itipmsg is None:
+            # Log and ignore this situation
+            log.debug("Empty iTIP attendee reply: Attendee '{attendee}', UID: {uid}".format(attendee=self.attendee, uid=self.uid))
+            return succeed(None)
 
         if config.Scheduling.Options.WorkQueues.Enabled:
             return ScheduleReplyWork.reply(self.txn, self.calendar_home, None, itipmsg, self.attendee)

Modified: CalendarServer/trunk/txdav/caldav/datastore/scheduling/itip.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/scheduling/itip.py	2015-05-27 18:24:04 UTC (rev 14835)
+++ CalendarServer/trunk/txdav/caldav/datastore/scheduling/itip.py	2015-05-27 18:25:43 UTC (rev 14836)
@@ -1124,9 +1124,12 @@
             if component.name() == "VPOLL":
                 iTipGenerator.generateVPOLLReply(component, attendee)
 
-        return itip
+        # After all the processing check that we have a valid component - one with a valid UID
+        uid = itip.resourceUID()
 
+        return itip if uid is not None else None
 
+
     @staticmethod
     def generateVPOLLReply(vpoll, attendee):
         """

Modified: CalendarServer/trunk/txdav/caldav/datastore/scheduling/test/test_implicit.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/scheduling/test/test_implicit.py	2015-05-27 18:24:04 UTC (rev 14835)
+++ CalendarServer/trunk/txdav/caldav/datastore/scheduling/test/test_implicit.py	2015-05-27 18:25:43 UTC (rev 14836)
@@ -1713,7 +1713,99 @@
         self.assertEqual(len(list2), 1)
 
 
+    @inlineCallbacks
+    def test_sendAttendeeReply_ScheduleAgentNone(self):
+        """
+        Test that sendAttendeeReply does nothing when the Organizer has
+        SCHEDULE-AGENT=NONE.
+        """
 
+        data1 = """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890
+DTSTAMP:20080601T120000Z
+DTSTART:20140302T190000Z
+DURATION:PT1H
+ORGANIZER;SCHEDULE-AGENT=NONE;CN="User 01":mailto:user01 at example.com
+ATTENDEE:mailto:user01 at example.com
+ATTENDEE:mailto:user02 at example.com
+RRULE:FREQ=DAILY;UNTIL=20140309T075959Z
+END:VEVENT
+END:VCALENDAR
+"""
+        yield self._createCalendarObject(data1, "user02", "test.ics")
+
+        cobj = yield self.calendarObjectUnderTest(home="user02", name="test.ics",)
+        result = yield ImplicitScheduler().sendAttendeeReply(cobj._txn, cobj)
+        self.assertFalse(result)
+
+
+    @inlineCallbacks
+    def test_sendAttendeeReply_ScheduleAgentClient(self):
+        """
+        Test that sendAttendeeReply does nothing when the Organizer has
+        SCHEDULE-AGENT=CLIENT.
+        """
+
+        data1 = """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890
+DTSTAMP:20080601T120000Z
+DTSTART:20140302T190000Z
+DURATION:PT1H
+ORGANIZER;SCHEDULE-AGENT=CLIENT;CN="User 01":mailto:user01 at example.com
+ATTENDEE:mailto:user01 at example.com
+ATTENDEE:mailto:user02 at example.com
+RRULE:FREQ=DAILY;UNTIL=20140309T075959Z
+END:VEVENT
+END:VCALENDAR
+"""
+        yield self._createCalendarObject(data1, "user02", "test.ics")
+
+        cobj = yield self.calendarObjectUnderTest(home="user02", name="test.ics",)
+        result = yield ImplicitScheduler().sendAttendeeReply(cobj._txn, cobj)
+        self.assertFalse(result)
+
+
+    @inlineCallbacks
+    def test_sendAttendeeReply_NoAttendee(self):
+        """
+        Test that sendAttendeeReply does nothing when the Attencdee is not
+        listed in the event. This will not normally ever be possible, but a case
+        like this was seen due to a processing error elsewehere.
+        """
+
+        data1 = """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890
+DTSTAMP:20080601T120000Z
+DTSTART:20140302T190000Z
+DURATION:PT1H
+ORGANIZER;CN="User 01":mailto:user01 at example.com
+ATTENDEE:mailto:user01 at example.com
+ATTENDEE:mailto:user03 at example.com
+RRULE:FREQ=DAILY;UNTIL=20140309T075959Z
+END:VEVENT
+END:VCALENDAR
+"""
+        yield self._createCalendarObject(data1, "user02", "test.ics")
+
+        cobj = yield self.calendarObjectUnderTest(home="user02", name="test.ics",)
+
+        # Need to remove SCHEDULE-AGENT=NONE on ORGANIZER as that will have been added during the store operation
+        cal = yield cobj.componentForUser()
+        cal.removePropertyParameters("ORGANIZER", ("SCHEDULE-AGENT", "SCHEDULE-STATUS",))
+        result = yield ImplicitScheduler().sendAttendeeReply(cobj._txn, cobj)
+        self.assertFalse(result)
+
+
+
 class ScheduleAgentFixBase(CommonCommonTests, TestCase):
     """
     Test txdav.caldav.datastore.scheduling.implicit.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20150527/c56fab7b/attachment.html>


More information about the calendarserver-changes mailing list