<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[13250] CalendarServer/trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.calendarserver.org//changeset/13250">13250</a></dd>
<dt>Author</dt> <dd>gaya@apple.com</dd>
<dt>Date</dt> <dd>2014-04-10 15:30:44 -0700 (Thu, 10 Apr 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Use canonical calendar user address for group attendees and vCard X-ADDRESSBOOKSERVER-MEMBER</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#CalendarServertrunktwistedcaldavicalpy">CalendarServer/trunk/twistedcaldav/ical.py</a></li>
<li><a href="#CalendarServertrunktxdavcaldavdatastoresqlpy">CalendarServer/trunk/txdav/caldav/datastore/sql.py</a></li>
<li><a href="#CalendarServertrunktxdavwhotesttest_group_attendeespy">CalendarServer/trunk/txdav/who/test/test_group_attendees.py</a></li>
<li><a href="#CalendarServertrunktxdavwhovcardpy">CalendarServer/trunk/txdav/who/vcard.py</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="CalendarServertrunktwistedcaldavicalpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/twistedcaldav/ical.py (13249 => 13250)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/twistedcaldav/ical.py        2014-04-10 20:15:48 UTC (rev 13249)
+++ CalendarServer/trunk/twistedcaldav/ical.py        2014-04-10 22:30:44 UTC (rev 13250)
</span><span class="lines">@@ -3384,22 +3384,20 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @inlineCallbacks
</span><del>-    def expandGroupAttendee(self, groupGUID, memberGUIDs, recordFunction):
</del><ins>+    def expandGroupAttendee(self, groupCUA, memberCUAs, recordFunction):
</ins><span class="cx"> 
</span><del>-        memberUUIDs = set([&quot;urn:uuid:&quot; + str(memberGUID) for memberGUID in memberGUIDs])
-        groupUUID = &quot;urn:uuid:&quot; + str(groupGUID)
</del><span class="cx">         changed = False
</span><span class="cx">         for component in self.subcomponents():
</span><span class="cx">             if component.name() in ignoredComponents:
</span><span class="cx">                 continue
</span><span class="cx"> 
</span><span class="cx">             oldAttendeeProps = tuple(component.properties(&quot;ATTENDEE&quot;))
</span><del>-            oldAttendeeUUIDs = set([attendeeProp.value() for attendeeProp in oldAttendeeProps])
</del><ins>+            oldAttendeeCUAs = set([attendeeProp.value() for attendeeProp in oldAttendeeProps])
</ins><span class="cx"> 
</span><span class="cx">             # add new member attendees
</span><del>-            for memberUUID in sorted(memberUUIDs - oldAttendeeUUIDs):
-                directoryRecord = yield recordFunction(memberUUID)
-                newAttendeeProp = directoryRecord.attendee(params={&quot;MEMBER&quot;: groupUUID})
</del><ins>+            for memberCUA in sorted(set(memberCUAs) - oldAttendeeCUAs):
+                directoryRecord = yield recordFunction(memberCUA)
+                newAttendeeProp = directoryRecord.attendee(params={&quot;MEMBER&quot;: groupCUA})
</ins><span class="cx">                 component.addProperty(newAttendeeProp)
</span><span class="cx">                 changed = True
</span><span class="cx"> 
</span><span class="lines">@@ -3407,15 +3405,15 @@
</span><span class="cx">             for attendeeProp in oldAttendeeProps:
</span><span class="cx">                 if attendeeProp.hasParameter(&quot;MEMBER&quot;):
</span><span class="cx">                     parameterValues = tuple(attendeeProp.parameterValues(&quot;MEMBER&quot;))
</span><del>-                    if groupUUID in parameterValues:
-                        if attendeeProp.value() not in memberUUIDs:
-                            attendeeProp.removeParameterValue(&quot;MEMBER&quot;, groupUUID)
</del><ins>+                    if groupCUA in parameterValues:
+                        if attendeeProp.value() not in memberCUAs:
+                            attendeeProp.removeParameterValue(&quot;MEMBER&quot;, groupCUA)
</ins><span class="cx">                             if not attendeeProp.parameterValues(&quot;MEMBER&quot;):
</span><span class="cx">                                 component.removeProperty(attendeeProp)
</span><span class="cx">                             changed = True
</span><span class="cx">                     else:
</span><del>-                        if attendeeProp.value() in memberUUIDs:
-                            attendeeProp.setParameter(&quot;MEMBER&quot;, parameterValues + (groupUUID,))
</del><ins>+                        if attendeeProp.value() in memberCUAs:
+                            attendeeProp.setParameter(&quot;MEMBER&quot;, parameterValues + (groupCUA,))
</ins><span class="cx">                             changed = True
</span><span class="cx"> 
</span><span class="cx">         returnValue(changed)
</span></span></pre></div>
<a id="CalendarServertrunktxdavcaldavdatastoresqlpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/caldav/datastore/sql.py (13249 => 13250)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/caldav/datastore/sql.py        2014-04-10 20:15:48 UTC (rev 13249)
+++ CalendarServer/trunk/txdav/caldav/datastore/sql.py        2014-04-10 22:30:44 UTC (rev 13250)
</span><span class="lines">@@ -1937,30 +1937,29 @@
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         Expand group attendees
</span><span class="cx">         &quot;&quot;&quot;
</span><del>-
</del><span class="cx">         if not config.Scheduling.Options.AllowGroupAsAttendee:
</span><span class="cx">             return
</span><span class="cx"> 
</span><span class="cx">         attendeeProps = component.getAllAttendeeProperties()
</span><del>-        groupGUIDs = set([
-            uuid.UUID(attendeeProp.value()[len(&quot;urn:uuid:&quot;):]) for attendeeProp in attendeeProps
</del><ins>+        groupCUAs = set([
+            attendeeProp.value() for attendeeProp in attendeeProps
</ins><span class="cx">             if attendeeProp.parameterValue(&quot;CUTYPE&quot;) == &quot;GROUP&quot;
</span><span class="cx">         ])
</span><ins>+        for groupCUA in groupCUAs:
</ins><span class="cx"> 
</span><del>-        for groupGUID in groupGUIDs:
-
-            groupRecord = yield self.directoryService().recordWithGUID(groupGUID)
</del><ins>+            groupRecord = yield self.directoryService().recordWithCalendarUserAddress(groupCUA)
</ins><span class="cx">             if groupRecord:
</span><span class="cx">                 members = yield groupRecord.expandedMembers()
</span><del>-                memberGUIDs = sorted([member.guid for member in members])
</del><span class="cx"> 
</span><ins>+                # calculate hash
+                memberUIDs = sorted([member.uid for member in members])
</ins><span class="cx">                 membershipHashContent = hashlib.md5()
</span><del>-                for memberGUID in memberGUIDs:
-                    membershipHashContent.update(str(memberGUID))
</del><ins>+                for memberUID in memberUIDs:
+                    membershipHashContent.update(memberUID)
</ins><span class="cx">                 membershipHash = membershipHashContent.hexdigest()
</span><span class="cx"> 
</span><span class="cx">                 # associate group ID with self
</span><del>-                groupID, _ignore_name, membershipHash, _ignore_modDate = yield self._txn.groupByUID(str(groupGUID))
</del><ins>+                groupID, _ignore_name, membershipHash, _ignore_modDate = yield self._txn.groupByUID(groupRecord.uid)
</ins><span class="cx">                 try:
</span><span class="cx">                     groupAttendee = schema.GROUP_ATTENDEE
</span><span class="cx">                     yield Insert({
</span><span class="lines">@@ -1972,7 +1971,11 @@
</span><span class="cx">                     pass
</span><span class="cx"> 
</span><span class="cx">                 # get members
</span><del>-                yield component.expandGroupAttendee(groupGUID, memberGUIDs, self.directoryService().recordWithCalendarUserAddress)
</del><ins>+                yield component.expandGroupAttendee(
+                    groupRecord.canonicalCalendarUserAddress(),
+                    set([member.canonicalCalendarUserAddress() for member in members]),
+                    self.directoryService().recordWithCalendarUserAddress
+                )
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     def validCalendarDataCheck(self, component, inserting):
</span></span></pre></div>
<a id="CalendarServertrunktxdavwhotesttest_group_attendeespy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/who/test/test_group_attendees.py (13249 => 13250)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/who/test/test_group_attendees.py        2014-04-10 20:15:48 UTC (rev 13249)
+++ CalendarServer/trunk/txdav/who/test/test_group_attendees.py        2014-04-10 22:30:44 UTC (rev 13250)
</span><span class="lines">@@ -317,8 +317,8 @@
</span><span class="cx"> ATTENDEE;CN=User 01;EMAIL=user01@example.com;RSVP=TRUE:urn:uuid:10000000-0000-0000-0000-000000000001
</span><span class="cx"> ATTENDEE;CN=Group 02;CUTYPE=GROUP;EMAIL=group02@example.com;RSVP=TRUE;SCHEDULE-STATUS=3.7:urn:uuid:20000000-0000-0000-0000-000000000002
</span><span class="cx"> ATTENDEE;CN=Group 04;CUTYPE=GROUP;RSVP=TRUE;SCHEDULE-STATUS=3.7:urn:uuid:20000000-0000-0000-0000-000000000004
</span><del>-ATTENDEE;CN=User 06;EMAIL=user06@example.com;MEMBER=&quot;urn:uuid:20000000-0000-0000-0000-000000000002&quot;,&quot;urn:uuid:20000000-0000-0000-0000-000000000004&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:uuid:10000000-0000-0000-0000-000000000006
-ATTENDEE;CN=User 07;EMAIL=user07@example.com;MEMBER=&quot;urn:uuid:20000000-0000-0000-0000-000000000002&quot;,&quot;urn:uuid:20000000-0000-0000-0000-000000000004&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:uuid:10000000-0000-0000-0000-000000000007
</del><ins>+ATTENDEE;CN=User 06;EMAIL=user06@example.com;MEMBER=&quot;urn:uuid:20000000-0000-0000-0000-000000000004&quot;,&quot;urn:uuid:20000000-0000-0000-0000-000000000002&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:uuid:10000000-0000-0000-0000-000000000006
+ATTENDEE;CN=User 07;EMAIL=user07@example.com;MEMBER=&quot;urn:uuid:20000000-0000-0000-0000-000000000004&quot;,&quot;urn:uuid:20000000-0000-0000-0000-000000000002&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:uuid:10000000-0000-0000-0000-000000000007
</ins><span class="cx"> ATTENDEE;CN=User 08;EMAIL=user08@example.com;MEMBER=&quot;urn:uuid:20000000-0000-0000-0000-000000000004&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:uuid:10000000-0000-0000-0000-000000000008
</span><span class="cx"> ATTENDEE;CN=User 09;EMAIL=user09@example.com;MEMBER=&quot;urn:uuid:20000000-0000-0000-0000-000000000004&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:uuid:10000000-0000-0000-0000-000000000009
</span><span class="cx"> ATTENDEE;CN=User 10;EMAIL=user10@example.com;MEMBER=&quot;urn:uuid:20000000-0000-0000-0000-000000000004&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:uuid:10000000-0000-0000-0000-000000000010
</span></span></pre></div>
<a id="CalendarServertrunktxdavwhovcardpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/who/vcard.py (13249 => 13250)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/who/vcard.py        2014-04-10 20:15:48 UTC (rev 13249)
+++ CalendarServer/trunk/txdav/who/vcard.py        2014-04-10 22:30:44 UTC (rev 13250)
</span><span class="lines">@@ -322,7 +322,7 @@
</span><span class="cx">     # FIXME:  members() is a deferred, so all of vCardFromRecord is deferred.
</span><span class="cx">     for memberRecord in (yield record.members()):
</span><span class="cx">         if memberRecord:
</span><del>-            vcard.addProperty(Property(&quot;X-ADDRESSBOOKSERVER-MEMBER&quot;, &quot;urn:uuid:&quot; + memberRecord.fields[FieldName.uid].encode(&quot;utf-8&quot;)))
</del><ins>+            vcard.addProperty(Property(&quot;X-ADDRESSBOOKSERVER-MEMBER&quot;, memberRecord.canonicalCalendarUserAddress().encode(&quot;utf-8&quot;)))
</ins><span class="cx"> 
</span><span class="cx">     #===================================================================
</span><span class="cx">     # vCard 4.0  http://tools.ietf.org/html/rfc6350
</span></span></pre>
</div>
</div>

</body>
</html>