[CalendarServer-changes] [3130] CalendarServer/trunk/twistedcaldav/mail.py

source_changes at macosforge.org source_changes at macosforge.org
Tue Oct 7 16:23:07 PDT 2008


Revision: 3130
          http://trac.macosforge.org/projects/calendarserver/changeset/3130
Author:   sagen at apple.com
Date:     2008-10-07 16:23:06 -0700 (Tue, 07 Oct 2008)
Log Message:
-----------
Set disposition to inline for calendar mime parts; use organizer's CN if available for the From address

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

Modified: CalendarServer/trunk/twistedcaldav/mail.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/mail.py	2008-10-07 19:39:31 UTC (rev 3129)
+++ CalendarServer/trunk/twistedcaldav/mail.py	2008-10-07 23:23:06 UTC (rev 3130)
@@ -614,10 +614,12 @@
         calendar.removeAllButOneAttendee(attendee)
         organizerProperty = calendar.getOrganizerProperty()
         if organizerProperty is None:
-            # this calendar body is incomplete, skip it
-            self.log_error("Mail gateway didn't find an organizer in message %s" % (msg['Message-ID'],))
-            return
-        organizerProperty.setValue(organizer)
+            # ORGANIZER is required per rfc2446 section 3.2.3
+            self.log_warning("Mail gateway didn't find an ORGANIZER in REPLY %s" % (msg['Message-ID'],))
+            calendar.addProperty(Property("ORGANIZER", organizer))
+        else:
+            organizerProperty.setValue(organizer)
+
         return fn(organizer, attendee, calendar, msg['Message-ID'])
 
 
@@ -664,18 +666,22 @@
 
         msgId, message = self._generateTemplateMessage(calendar, organizer)
 
-        # The email's From: will be the calendar server's address (without
-        # + addressing), while the Reply-To: will be the organizer's email
-        # address (but only if it *is* an email address).
+        # The email's From will include the organizer's real name email
+        # address if available.  Otherwise it will be the server's email
+        # address (without # + addressing)
         if organizer.startswith("mailto:"):
-            message = message.replace("${replytoaddress}", organizer[7:])
+            fromAddr = organizer[7:]
         else:
-            message = message.replace("${replytoaddress}", addressWithToken)
+            fromAddr = serverAddress
+        cn = calendar.getOrganizerProperty().params().get('CN',
+            ['Calendar Server'])[0]
+        formattedFrom = "%s <%s>" % (cn, fromAddr)
+        message = message.replace("${fromaddress}", formattedFrom)
 
-        fromAddr = serverAddress
+        # Reply-to address will be the server+token address
+        message = message.replace("${replytoaddress}", addressWithToken)
+
         toAddr = attendee
-        message = message.replace("${fromaddress}", fromAddr)
-
         if not attendee.startswith("mailto:"):
             raise ValueError("ATTENDEE address '%s' must be mailto: for iMIP operation." % (attendee,))
         attendee = attendee[7:]
@@ -754,11 +760,12 @@
         method = calendar.propertyValue("METHOD").lower()
         msgIcal.set_param("method", method)
         msgIcal.add_header("Content-Disposition",
-            "attachment;filename=invitation.ics")
+            "inline;filename=invitation.ics")
         msg.attach(msgIcal)
 
         return msgId, msg.as_string()
 
+
     def _generateCalendarSummary(self, calendar, organizer):
 
         # Get the most appropriate component
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20081007/d224aa12/attachment.html 


More information about the calendarserver-changes mailing list