[CalendarServer-changes] [5560] CalendarServer/trunk/twistedcaldav

source_changes at macosforge.org source_changes at macosforge.org
Tue May 4 15:25:38 PDT 2010


Revision: 5560
          http://trac.macosforge.org/projects/calendarserver/changeset/5560
Author:   sagen at apple.com
Date:     2010-05-04 15:25:37 -0700 (Tue, 04 May 2010)
Log Message:
-----------
When an imip reply is missing the appropriate ATTENDEE (because the client made
an unexpected ATTENDEE substitution), add the right ATTENDEE back into the reply
with a SCHEDULE-STATUS of 5.1;Service unavailable before injecting.  The
organizer will then see there was a problem and can contact the attendee.
Prior to this, the reply was dropped on the floor.

Modified Paths:
--------------
    CalendarServer/trunk/twistedcaldav/mail.py
    CalendarServer/trunk/twistedcaldav/test/test_mail.py

Modified: CalendarServer/trunk/twistedcaldav/mail.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/mail.py	2010-05-04 00:06:31 UTC (rev 5559)
+++ CalendarServer/trunk/twistedcaldav/mail.py	2010-05-04 22:25:37 UTC (rev 5560)
@@ -62,6 +62,7 @@
 from twistedcaldav.ical import Property
 from twistedcaldav.localization import translationTo
 from twistedcaldav.scheduling.cuaddress import normalizeCUAddr
+from twistedcaldav.scheduling.itip import iTIPRequestStatus
 from twistedcaldav.scheduling.scheduler import IMIPScheduler
 from twistedcaldav.sql import AbstractSQLDatabase
 from twistedcaldav.static import CalDAVFile, deliverSchedulePrivilegeSet
@@ -718,6 +719,7 @@
 
         self.log_debug(calBody)
         calendar = ical.Component.fromString(calBody)
+        event = calendar.mainComponent()
 
         # process mail messages from POP or IMAP, inject to calendar server
         result = self.db.lookupByToken(token)
@@ -735,10 +737,26 @@
         if organizerProperty is None:
             # ORGANIZER is required per rfc2446 section 3.2.3
             self.log_warn("Mail gateway didn't find an ORGANIZER in REPLY %s" % (msg['Message-ID'],))
-            calendar.addProperty(Property("ORGANIZER", organizer))
+            event.addProperty(Property("ORGANIZER", organizer))
         else:
             organizerProperty.setValue(organizer)
 
+        if not calendar.getAttendees():
+            # The attendee we're expecting isn't there, so add it back
+            # with a SCHEDULE-STATUS of SERVICE_UNAVAILABLE.
+            # The organizer will then see that the reply was not successful.
+            attendeeProp = Property("ATTENDEE", attendee,
+                params = {
+                    "SCHEDULE-STATUS": [iTIPRequestStatus.SERVICE_UNAVAILABLE],
+                }
+            )
+            event.addProperty(attendeeProp)
+
+            # TODO: We have talked about sending an email to the reply-to
+            # at this point, to let them know that their reply was missing
+            # the appropriate ATTENDEE.  This will require a new localizable
+            # email template for the message.
+
         return fn(organizer, attendee, calendar, msg['Message-ID'])
 
 

Modified: CalendarServer/trunk/twistedcaldav/test/test_mail.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/test/test_mail.py	2010-05-04 00:06:31 UTC (rev 5559)
+++ CalendarServer/trunk/twistedcaldav/test/test_mail.py	2010-05-04 22:25:37 UTC (rev 5560)
@@ -18,7 +18,9 @@
 from twistedcaldav.test.util import TestCase
 from twistedcaldav.ical import Component
 from twistedcaldav.config import config
+from twistedcaldav.scheduling.itip import iTIPRequestStatus
 
+
 from twisted.internet.defer import inlineCallbacks
 import email
 import os
@@ -108,9 +110,28 @@
 
         organizer, attendee, calendar, msgId = self.handler.processReply(msg,
             echo)
+        organizerProp = calendar.mainComponent().getOrganizerProperty()
+        self.assertTrue(organizerProp is not None)
         self.assertEquals(organizer, "mailto:user01 at example.com")
 
+    def test_processReplyMissingAttendee(self):
+        msg = email.message_from_string(
+            file(os.path.join(self.dataDir, 'reply_missing_attendee')).read()
+        )
+        # stick the token in the database first
+        self.handler.db.createToken("mailto:user01 at example.com", "mailto:xyzzy at example.com", icaluid="1E71F9C8-AEDA-48EB-98D0-76E898F6BB5C", token="d7cdf68d-8b73-4df1-ad3b-f08002fb285f")
 
+        organizer, attendee, calendar, msgId = self.handler.processReply(msg,
+            echo)
+
+        # Since the expected attendee was missing, the reply processor should
+        # have added an attendee back in with a "5.1;Service unavailable"
+        # schedule-status
+        attendeeProp = calendar.mainComponent().getAttendeeProperty([attendee])
+        self.assertEquals(attendeeProp.paramValue("SCHEDULE-STATUS"),
+            iTIPRequestStatus.SERVICE_UNAVAILABLE)
+
+
     @inlineCallbacks
     def test_outbound(self):
         """
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100504/b372a0b2/attachment.html>


More information about the calendarserver-changes mailing list