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

source_changes at macosforge.org source_changes at macosforge.org
Mon Aug 22 14:01:03 PDT 2011


Revision: 8004
          http://trac.macosforge.org/projects/calendarserver/changeset/8004
Author:   sagen at apple.com
Date:     2011-08-22 14:01:02 -0700 (Mon, 22 Aug 2011)
Log Message:
-----------
Honor mail tokens from the past that were stored with mailto: addresses

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	2011-08-22 18:42:13 UTC (rev 8003)
+++ CalendarServer/trunk/twistedcaldav/mail.py	2011-08-22 21:01:02 UTC (rev 8004)
@@ -1114,11 +1114,21 @@
             # event uid
             token = self.db.getToken(originator, toAddr, icaluid)
             if token is None:
+
+                # Because in the past the originator was sometimes in mailto:
+                # form, lookup an existing token by mailto: as well
+                organizerProperty = calendar.getOrganizerProperty()
+                organizerEmailAddress = organizerProperty.parameterValue("EMAIL", None)
+                if organizerEmailAddress is not None:
+                    token = self.db.getToken("mailto:%s" % (organizerEmailAddress,), toAddr, icaluid)
+
+            if token is None:
                 token = self.db.createToken(originator, toAddr, icaluid)
                 self.log_debug("Mail gateway created token %s for %s "
                                "(originator), %s (recipient) and %s (icaluid)"
                                % (token, originator, toAddr, icaluid))
                 inviteState = "new"
+
             else:
                 self.log_debug("Mail gateway reusing token %s for %s "
                                "(originator), %s (recipient) and %s (icaluid)"

Modified: CalendarServer/trunk/twistedcaldav/test/test_mail.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/test/test_mail.py	2011-08-22 18:42:13 UTC (rev 8003)
+++ CalendarServer/trunk/twistedcaldav/test/test_mail.py	2011-08-22 21:01:02 UTC (rev 8004)
@@ -491,6 +491,47 @@
                 self.assertEquals(actualReplyTo, actualFrom)
 
 
+    @inlineCallbacks
+    def test_mailtoTokens(self):
+        """
+        Make sure old mailto tokens are still honored
+        """
+
+        organizerEmail = "mailto:organizer at example.com"
+
+        config.Scheduling.iMIP.Sending.Address = "server at example.com"
+
+        # Explictly store a token with mailto: CUA for organizer
+        # (something that doesn't happen any more, but did in the past)
+        origToken = self.handler.db.createToken(organizerEmail,
+            "mailto:attendee at example.com",
+            "CFDD5E46-4F74-478A-9311-B3FF905449C3")
+
+        inputCalendar = initialInviteText
+        UID = "CFDD5E46-4F74-478A-9311-B3FF905449C3"
+        inputOriginator = "urn:uuid:C3B38B00-4166-11DD-B22C-A07C87E02F6A"
+        inputRecipient = "mailto:attendee at example.com"
+
+        (actualInviteState, actualCalendar, actualOrganizerEmail,
+            actualOrganizerName, actualAttendeeList, actualFrom,
+            actualRecipient, actualReplyTo) = (yield self.handler.outbound(
+                inputOriginator,
+                inputRecipient,
+                Component.fromString(inputCalendar.replace("\n", "\r\n")),
+                send=False)
+            )
+
+        # Verify we didn't create a new token...
+        token = self.handler.db.getToken(inputOriginator,
+            inputRecipient, UID)
+        self.assertEquals(token, None)
+
+        # But instead kept the old one...
+        token = self.handler.db.getToken(organizerEmail,
+            inputRecipient, UID)
+        self.assertEquals(token, origToken)
+
+
     def generateSampleEmail(self):
         """
         Invoke L{MailHandler.generateEmail} and parse the result.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110822/92f98b3c/attachment.html>


More information about the calendarserver-changes mailing list