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

source_changes at macosforge.org source_changes at macosforge.org
Wed Mar 28 14:28:03 PDT 2012


Revision: 8947
          http://trac.macosforge.org/projects/calendarserver/changeset/8947
Author:   sagen at apple.com
Date:     2012-03-28 14:28:03 -0700 (Wed, 28 Mar 2012)
Log Message:
-----------
Adds common-name, first-name, and last-name to invite-reply notifications.

Modified Paths:
--------------
    CalendarServer/trunk/twistedcaldav/customxml.py
    CalendarServer/trunk/twistedcaldav/sharing.py

Modified: CalendarServer/trunk/twistedcaldav/customxml.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/customxml.py	2012-03-28 21:27:28 UTC (rev 8946)
+++ CalendarServer/trunk/twistedcaldav/customxml.py	2012-03-28 21:28:03 UTC (rev 8947)
@@ -1120,6 +1120,9 @@
 
     allowed_children = {
         (dav_namespace, "href")                       : (0, 1),
+        (calendarserver_namespace, "common-name")     : (0, 1),
+        (calendarserver_namespace, "first-name")      : (0, 1),
+        (calendarserver_namespace, "last-name")       : (0, 1),
         (calendarserver_namespace, "invite-accepted") : (0, 1),
         (calendarserver_namespace, "invite-declined") : (0, 1),
         (calendarserver_namespace, "hosturl")         : (0, 1),

Modified: CalendarServer/trunk/twistedcaldav/sharing.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/sharing.py	2012-03-28 21:27:28 UTC (rev 8946)
+++ CalendarServer/trunk/twistedcaldav/sharing.py	2012-03-28 21:28:03 UTC (rev 8947)
@@ -1188,8 +1188,8 @@
         """
         
         # Change state in sharer invite
-        owner = (yield self.ownerPrincipal(request))
-        owner = owner.principalURL()
+        ownerPrincipal = (yield self.ownerPrincipal(request))
+        owner = ownerPrincipal.principalURL()
         sharedCollection = (yield request.locateResource(hostUrl))
         if sharedCollection is None:
             # Original shared collection is gone - nothing we can do except ignore it
@@ -1202,30 +1202,44 @@
         # Change the record
         yield sharedCollection.changeUserInviteState(request, replytoUID, owner, state, displayname)
 
-        yield self.sendReply(request, owner, sharedCollection, state, hostUrl, replytoUID, displayname)
+        yield self.sendReply(request, ownerPrincipal, sharedCollection, state, hostUrl, replytoUID, displayname)
 
     @inlineCallbacks
-    def sendReply(self, request, sharee, sharedCollection, state, hostUrl, replytoUID, displayname=None):
+    def sendReply(self, request, shareePrincipal, sharedCollection, state, hostUrl, replytoUID, displayname=None):
 
         # Locate notifications collection for sharer
         sharer = (yield sharedCollection.ownerPrincipal(request))
         notifications = (yield request.locateResource(sharer.notificationURL()))
-        
+
         # Generate invite XML
         notificationUID = "%s-reply" % (replytoUID,)
         xmltype = customxml.InviteReply()
+
+        # Prefer mailto:, otherwise use principal URL
+        for cua in shareePrincipal.calendarUserAddresses():
+            if cua.startswith("mailto:"):
+                break
+        else:
+            cua = shareePrincipal.principalURL()
+
+        commonName = shareePrincipal.displayName()
+        record = shareePrincipal.record
+
         xmldata = customxml.Notification(
             customxml.DTStamp.fromString(PyCalendarDateTime.getNowUTC().getText()),
             customxml.InviteReply(
                 *(
                     (
-                        element.HRef.fromString(sharee),
+                        element.HRef.fromString(cua),
                         inviteStatusMapToXML[state](),
                         customxml.HostURL(
                             element.HRef.fromString(hostUrl),
                         ),
                         customxml.InReplyTo.fromString(replytoUID),
                     ) + ((customxml.InviteSummary.fromString(displayname),) if displayname is not None else ())
+                      + ((customxml.CommonName.fromString(commonName),) if commonName is not None else ())
+                      + ((customxml.FirstNameProperty(record.firstName),) if record.firstName is not None else ())
+                      + ((customxml.LastNameProperty(record.lastName),) if record.lastName is not None else ())
                 )
             ),
         ).toxml()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20120328/8b5b5efd/attachment.html>


More information about the calendarserver-changes mailing list