<!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>[14688] 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/14688">14688</a></dd>
<dt>Author</dt> <dd>cdaboo@apple.com</dd>
<dt>Date</dt> <dd>2015-04-20 11:00:40 -0700 (Mon, 20 Apr 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Re-factor free busy to push fbset loop lower down in the call stack.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#CalendarServertrunktwistedcaldavfreebusyurlpy">CalendarServer/trunk/twistedcaldav/freebusyurl.py</a></li>
<li><a href="#CalendarServertrunktwistedcaldavmethodreport_freebusypy">CalendarServer/trunk/twistedcaldav/method/report_freebusy.py</a></li>
<li><a href="#CalendarServertrunktxdavcaldavdatastoreschedulingcaldavdeliverypy">CalendarServer/trunk/txdav/caldav/datastore/scheduling/caldav/delivery.py</a></li>
<li><a href="#CalendarServertrunktxdavcaldavdatastoreschedulingfreebusypy">CalendarServer/trunk/txdav/caldav/datastore/scheduling/freebusy.py</a></li>
<li><a href="#CalendarServertrunktxdavcaldavdatastoreschedulingprocessingpy">CalendarServer/trunk/txdav/caldav/datastore/scheduling/processing.py</a></li>
<li><a href="#CalendarServertrunktxdavcaldavdatastoreschedulingtesttest_freebusypy">CalendarServer/trunk/txdav/caldav/datastore/scheduling/test/test_freebusy.py</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastorepoddingstore_apipy">CalendarServer/trunk/txdav/common/datastore/podding/store_api.py</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastorepoddingtesttest_conduitpy">CalendarServer/trunk/txdav/common/datastore/podding/test/test_conduit.py</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="CalendarServertrunktwistedcaldavfreebusyurlpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/twistedcaldav/freebusyurl.py (14687 => 14688)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/twistedcaldav/freebusyurl.py        2015-04-17 21:05:17 UTC (rev 14687)
+++ CalendarServer/trunk/twistedcaldav/freebusyurl.py        2015-04-20 18:00:40 UTC (rev 14688)
</span><span class="lines">@@ -270,10 +270,12 @@
</span><span class="cx">         attendeeProp = Property(&quot;ATTENDEE&quot;, recipient.cuaddr)
</span><span class="cx">         timerange = Period(self.start, self.end)
</span><span class="cx"> 
</span><del>-        fbresult = (yield FreebusyQuery(
-            organizer, None, recipient, attendeeProp, None,
-            timerange, None, None,
-        ).generateAttendeeFreeBusyResponse())
</del><ins>+        fbresult = yield FreebusyQuery(
+            organizer=organizer,
+            recipient=recipient,
+            attendeeProp=attendeeProp,
+            timerange=timerange,
+        ).generateAttendeeFreeBusyResponse()
</ins><span class="cx"> 
</span><span class="cx">         response = Response()
</span><span class="cx">         response.stream = MemoryStream(str(fbresult))
</span></span></pre></div>
<a id="CalendarServertrunktwistedcaldavmethodreport_freebusypy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/twistedcaldav/method/report_freebusy.py (14687 => 14688)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/twistedcaldav/method/report_freebusy.py        2015-04-17 21:05:17 UTC (rev 14687)
+++ CalendarServer/trunk/twistedcaldav/method/report_freebusy.py        2015-04-20 18:00:40 UTC (rev 14688)
</span><span class="lines">@@ -37,6 +37,7 @@
</span><span class="cx"> from twistedcaldav.util import bestAcceptType
</span><span class="cx"> 
</span><span class="cx"> from txdav.caldav.icalendarstore import TimeRangeLowerLimit, TimeRangeUpperLimit
</span><ins>+from txdav.caldav.datastore.scheduling.cuaddress import LocalCalendarUser
</ins><span class="cx"> from txdav.caldav.datastore.scheduling.freebusy import FreebusyQuery
</span><span class="cx"> from txdav.xml import element as davxml
</span><span class="cx"> 
</span><span class="lines">@@ -85,12 +86,11 @@
</span><span class="cx">     yield report_common.applyToCalendarCollections(self, request, request.uri, depth, getCalendarList, (caldavxml.ReadFreeBusy(),))
</span><span class="cx"> 
</span><span class="cx">     # Do the actual freebusy query against the set of matched calendars
</span><ins>+    principal = yield self.ownerPrincipal(request)
+    organizer = recipient = LocalCalendarUser(principal.canonicalCalendarUserAddress(), principal.record)
</ins><span class="cx">     timerange = Period(timerange.start, timerange.end)
</span><span class="cx">     try:
</span><del>-        fbresult = (yield FreebusyQuery(
-            None, None, None, None, None,
-            timerange, None, None,
-        ).generateAttendeeFreeBusyResponse(fbset=fbset, method=None))
</del><ins>+        fbresult = yield FreebusyQuery(organizer=organizer, recipient=recipient, timerange=timerange).generateAttendeeFreeBusyResponse(fbset=fbset, method=None)
</ins><span class="cx">     except NumberOfMatchesWithinLimits:
</span><span class="cx">         log.error(&quot;Too many matching components in free-busy report&quot;)
</span><span class="cx">         raise HTTPError(ErrorResponse(
</span></span></pre></div>
<a id="CalendarServertrunktxdavcaldavdatastoreschedulingcaldavdeliverypy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/caldav/datastore/scheduling/caldav/delivery.py (14687 => 14688)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/caldav/datastore/scheduling/caldav/delivery.py        2015-04-17 21:05:17 UTC (rev 14687)
+++ CalendarServer/trunk/txdav/caldav/datastore/scheduling/caldav/delivery.py        2015-04-20 18:00:40 UTC (rev 14688)
</span><span class="lines">@@ -200,11 +200,17 @@
</span><span class="cx">         attendeeProp = self.scheduler.calendar.getAttendeeProperty(cuas)
</span><span class="cx"> 
</span><span class="cx">         try:
</span><del>-            fbresult = (yield FreebusyQuery(
-                self.scheduler.organizer, organizerProp, recipient, attendeeProp, uid,
-                self.scheduler.timeRange, self.scheduler.excludeUID, self.scheduler.logItems,
</del><ins>+            fbresult = yield FreebusyQuery(
+                organizer=self.scheduler.organizer,
+                organizerProp=organizerProp,
+                recipient=recipient,
+                attendeeProp=attendeeProp,
+                uid=uid,
+                timerange=self.scheduler.timeRange,
+                excludeUID=self.scheduler.excludeUID,
+                logItems=self.scheduler.logItems,
</ins><span class="cx">                 event_details=event_details,
</span><del>-            ).generateAttendeeFreeBusyResponse())
</del><ins>+            ).generateAttendeeFreeBusyResponse()
</ins><span class="cx">         except Exception as e:
</span><span class="cx">             log.failure(
</span><span class="cx">                 &quot;Could not determine free busy information for recipient {cuaddr}&quot;,
</span></span></pre></div>
<a id="CalendarServertrunktxdavcaldavdatastoreschedulingfreebusypy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/caldav/datastore/scheduling/freebusy.py (14687 => 14688)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/caldav/datastore/scheduling/freebusy.py        2015-04-17 21:05:17 UTC (rev 14687)
+++ CalendarServer/trunk/txdav/caldav/datastore/scheduling/freebusy.py        2015-04-20 18:00:40 UTC (rev 14688)
</span><span class="lines">@@ -103,7 +103,11 @@
</span><span class="cx">     FBInfo_mapper = {&quot;BUSY&quot;: &quot;busy&quot;, &quot;BUSY-TENTATIVE&quot;: &quot;tentative&quot;, &quot;BUSY-UNAVAILABLE&quot;: &quot;unavailable&quot;}
</span><span class="cx">     FBInfo_index_mapper = {'B': &quot;busy&quot;, 'T': &quot;tentative&quot;, 'U': &quot;unavailable&quot;}
</span><span class="cx"> 
</span><del>-    def __init__(self, organizer, organizerProp, recipient, attendeeProp, uid, timeRange, excludeUID, logItems, accountingItems=None, event_details=None):
</del><ins>+    def __init__(
+        self,
+        organizer=None, organizerProp=None, recipient=None, attendeeProp=None,
+        uid=None, timerange=None, excludeUID=None, logItems=None, accountingItems=None, event_details=None
+    ):
</ins><span class="cx">         &quot;&quot;&quot;
</span><span class="cx"> 
</span><span class="cx">         @param organizer: the organizer making the freebusy request
</span><span class="lines">@@ -114,10 +118,13 @@
</span><span class="cx">         @type recipient: L{CalendarUser}
</span><span class="cx">         @param attendeeProp: iCalendar ATTENDEE property from the request
</span><span class="cx">         @type attendeeProp: L{Property}
</span><ins>+        @param authzuid: directory UID of the currently authenticated user (i.e., the one making
+            the actual free busy request - might be different from the organizer)
+        @type authzuid: L{str}
</ins><span class="cx">         @param uid: iCalendar UID in the request
</span><span class="cx">         @type uid: L{str}
</span><del>-        @param timeRange: time range for freebusy request
-        @type timeRange: L{Period}
</del><ins>+        @param timerange: time range for freebusy request
+        @type timerange: L{Period}
</ins><span class="cx">         @param excludeUID: an iCalendar UID to exclude from busy results
</span><span class="cx">         @type excludeUID: L{str}
</span><span class="cx">         @param logItems: items to add to logging
</span><span class="lines">@@ -132,7 +139,7 @@
</span><span class="cx">         self.recipient = recipient
</span><span class="cx">         self.attendeeProp = attendeeProp
</span><span class="cx">         self.uid = uid
</span><del>-        self.timerange = timeRange
</del><ins>+        self.timerange = timerange
</ins><span class="cx">         self.excludeuid = excludeUID
</span><span class="cx">         self.logItems = logItems
</span><span class="cx">         self.accountingItems = accountingItems
</span><span class="lines">@@ -145,8 +152,50 @@
</span><span class="cx">         else:
</span><span class="cx">             self.same_calendar_user = False
</span><span class="cx"> 
</span><ins>+        # May need organizer principal
+        self.organizer_record = self.organizer.record if self.organizer and self.organizer.hosted() else None
+        self.organizer_uid = self.organizer_record.uid if self.organizer_record else None
</ins><span class="cx"> 
</span><ins>+        # Free busy is per-user
+        self.attendee_record = self.recipient.record if self.recipient and self.recipient.hosted() else None
+        self.attendee_uid = self.attendee_record.uid if self.attendee_record else None
+
+
</ins><span class="cx">     @inlineCallbacks
</span><ins>+    def checkRichOptions(self, txn):
+        if not hasattr(self, &quot;rich_options&quot;):
+            # Look for possible extended free busy information
+            self.rich_options = {
+                &quot;organizer&quot;: False,
+                &quot;delegate&quot;: False,
+                &quot;resource&quot;: False,
+            }
+            if self.event_details is not None and self.organizer_record is not None and self.attendee_record is not None:
+
+                # Get the principal of the authorized user which may be different from the organizer if a delegate of
+                # the organizer is making the request
+                authzuid = txn._authz_uid if txn is not None else None
+                if authzuid is not None and authzuid != self.organizer_uid:
+                    authz_record = yield txn.directoryService().recordWithUID(authzuid.decode(&quot;utf-8&quot;))
+                else:
+                    self.authzuid = self.organizer_uid
+                    authz_record = self.organizer_record
+
+                # Check if attendee is also the organizer or the delegate doing the request
+                if self.attendee_uid in (self.organizer_uid, authzuid):
+                    self.rich_options[&quot;organizer&quot;] = True
+
+                # Check if authorized user is a delegate of attendee
+                proxy = (yield authz_record.isProxyFor(self.attendee_record))
+                if config.Scheduling.Options.DelegeteRichFreeBusy and proxy:
+                    self.rich_options[&quot;delegate&quot;] = True
+
+                # Check if attendee is room or resource
+                if config.Scheduling.Options.RoomResourceRichFreeBusy and self.attendee_record.getCUType() in (&quot;RESOURCE&quot;, &quot;ROOM&quot;,):
+                    self.rich_options[&quot;resource&quot;] = True
+
+
+    @inlineCallbacks
</ins><span class="cx">     def generateAttendeeFreeBusyResponse(self, fbset=None, method=&quot;REPLY&quot;):
</span><span class="cx"> 
</span><span class="cx">         # First list is BUSY, second BUSY-TENTATIVE, third BUSY-UNAVAILABLE
</span><span class="lines">@@ -159,18 +208,13 @@
</span><span class="cx">                 fbset = [calendar for calendar in fbset if calendar.isUsedForFreeBusy()]
</span><span class="cx"> 
</span><span class="cx">             # Process the availability property from the Inbox.
</span><del>-            availability = self.recipient.inbox.ownerHome().getAvailability()
-            if availability is not None:
-                self.processAvailabilityFreeBusy(availability, fbinfo)
</del><ins>+            if hasattr(self.recipient, &quot;inbox&quot;):
+                availability = self.recipient.inbox.ownerHome().getAvailability()
+                if availability is not None:
+                    self.processAvailabilityFreeBusy(availability, fbinfo)
</ins><span class="cx"> 
</span><span class="cx">         # Now process free-busy set calendars
</span><del>-        matchtotal = 0
-        for calendar in fbset:
-            matchtotal = (yield self.generateFreeBusyInfo(
-                calendar,
-                fbinfo,
-                matchtotal,
-            ))
</del><ins>+        yield self.generateFreeBusyInfo(fbset, fbinfo)
</ins><span class="cx"> 
</span><span class="cx">         # Build VFREEBUSY iTIP reply for this recipient
</span><span class="cx">         fbresult = self.buildFreeBusyResult(fbinfo, method=method)
</span><span class="lines">@@ -268,50 +312,63 @@
</span><span class="cx">         return periods
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-    def generateFreeBusyInfo(self, calresource, fbinfo, matchtotal):
</del><ins>+    @inlineCallbacks
+    def generateFreeBusyInfo(self, fbset, fbinfo, matchtotal=0):
</ins><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         Get freebusy information for a calendar. Different behavior for internal vs external calendars.
</span><span class="cx"> 
</span><span class="cx">         See L{_internalGenerateFreeBusyInfo} for argument description.
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx"> 
</span><del>-        # TODO: this method really should be moved to L{CalendarObject} so the internal/external pieces
-        # can be split across L{CalendarObject} and L{CalendarObjectExternal}
-        if calresource.external():
-            return self._externalGenerateFreeBusyInfo(
-                calresource,
</del><ins>+        # Split calendar set into internal/external items
+        fbset_internal = [calendar for calendar in fbset if not calendar.external()]
+        fbset_external = [calendar for calendar in fbset if calendar.external()]
+
+        # TODO: we should probably figure out how to run the internal and external ones in parallel
+        if fbset_external:
+            matchtotal += (yield self._externalGenerateFreeBusyInfo(
+                fbset_external,
</ins><span class="cx">                 fbinfo,
</span><span class="cx">                 matchtotal,
</span><del>-            )
-        else:
-            return self._internalGenerateFreeBusyInfo(
-                calresource,
</del><ins>+            ))
+
+        if fbset_internal:
+            matchtotal += (yield self._internalGenerateFreeBusyInfo(
+                fbset_internal,
</ins><span class="cx">                 fbinfo,
</span><span class="cx">                 matchtotal,
</span><del>-            )
</del><ins>+            ))
</ins><span class="cx"> 
</span><ins>+        returnValue(matchtotal)
</ins><span class="cx"> 
</span><ins>+
</ins><span class="cx">     @inlineCallbacks
</span><del>-    def _externalGenerateFreeBusyInfo(self, calresource, fbinfo, matchtotal):
</del><ins>+    def _externalGenerateFreeBusyInfo(self, fbset, fbinfo, matchtotal):
</ins><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         Generate a freebusy response for an external (cross-pod) calendar by making a cross-pod call. This will bypass
</span><span class="cx">         any type of smart caching on this pod in favor of using caching on the pod hosting the actual calendar data.
</span><span class="cx"> 
</span><span class="cx">         See L{_internalGenerateFreeBusyInfo} for argument description.
</span><span class="cx">         &quot;&quot;&quot;
</span><del>-        fbresults, matchtotal = yield calresource._txn.store().conduit.send_freebusy(
-            calresource, self.organizer.cuaddr, self.recipient.cuaddr, self.timerange,
-            matchtotal, self.excludeuid, self.event_details
-        )
-        for i in range(3):
-            fbinfo[i].extend([Period.parseText(p) for p in fbresults[i]])
</del><ins>+        for calresource in fbset:
+            fbresults, matchtotal = yield calresource._txn.store().conduit.send_freebusy(
+                calresource,
+                self.organizer.cuaddr if self.organizer else None,
+                self.recipient.cuaddr if self.recipient else None,
+                self.timerange,
+                matchtotal,
+                self.excludeuid,
+                self.event_details,
+            )
+            for i in range(3):
+                fbinfo[i].extend([Period.parseText(p) for p in fbresults[i]])
</ins><span class="cx">         returnValue(matchtotal)
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @inlineCallbacks
</span><span class="cx">     def _internalGenerateFreeBusyInfo(
</span><span class="cx">         self,
</span><del>-        calresource,
</del><ins>+        fbset,
</ins><span class="cx">         fbinfo,
</span><span class="cx">         matchtotal,
</span><span class="cx">     ):
</span><span class="lines">@@ -323,141 +380,34 @@
</span><span class="cx">         @param matchtotal:  the running total for the number of matches.
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx"> 
</span><del>-        # First check the privilege on this collection
-        # TODO: for server-to-server we bypass this right now as we have no way to authorize external users.
-        # TODO: actually we by pass altogether by assuming anyone can check anyone else's freebusy
</del><ins>+        yield self.checkRichOptions(fbset[0]._txn)
</ins><span class="cx"> 
</span><del>-        # May need organizer principal
-        organizer_record = self.organizer.record if self.organizer and self.organizer.hosted() else None
-        organizer_uid = organizer_record.uid if organizer_record else &quot;&quot;
</del><ins>+        calidmap = dict([(fbcalendar.id(), fbcalendar,) for fbcalendar in fbset])
+        directoryService = fbset[0].directoryService()
</ins><span class="cx"> 
</span><del>-        # Free busy is per-user
-        attendee_record = self.recipient.record if self.organizer and self.recipient.hosted() else None
-        attendee_uid = attendee_record.uid if attendee_record else calresource.viewerHome().uid()
</del><ins>+        resources, tzinfos = yield self._matchResources(fbset)
</ins><span class="cx"> 
</span><del>-        # Get the timezone property from the collection.
-        tz = calresource.getTimezone()
-
-        # Look for possible extended free busy information
-        rich_options = {
-            &quot;organizer&quot;: False,
-            &quot;delegate&quot;: False,
-            &quot;resource&quot;: False,
-        }
-        do_event_details = False
-        if self.event_details is not None and organizer_record is not None and attendee_record is not None:
-
-            # Get the principal of the authorized user which may be different from the organizer if a delegate of
-            # the organizer is making the request
-            authz_uid = organizer_uid
-            authz_record = organizer_record
-            if calresource._txn._authz_uid is not None and calresource._txn._authz_uid != organizer_uid:
-                authz_uid = calresource._txn._authz_uid
-                authz_record = yield calresource.directoryService().recordWithUID(authz_uid.decode(&quot;utf-8&quot;))
-
-            # Check if attendee is also the organizer or the delegate doing the request
-            if attendee_uid in (organizer_uid, authz_uid):
-                do_event_details = True
-                rich_options[&quot;organizer&quot;] = True
-
-            # Check if authorized user is a delegate of attendee
-            proxy = (yield authz_record.isProxyFor(attendee_record))
-            if config.Scheduling.Options.DelegeteRichFreeBusy and proxy:
-                do_event_details = True
-                rich_options[&quot;delegate&quot;] = True
-
-            # Check if attendee is room or resource
-            if config.Scheduling.Options.RoomResourceRichFreeBusy and attendee_record.getCUType() in (&quot;RESOURCE&quot;, &quot;ROOM&quot;,):
-                do_event_details = True
-                rich_options[&quot;resource&quot;] = True
-
-        # Try cache
-        resources = (yield FBCacheEntry.getCacheEntry(calresource, attendee_uid, self.timerange)) if config.EnableFreeBusyCache else None
-
-        if resources is None:
-
-            if self.accountingItems is not None:
-                self.accountingItems[&quot;fb-uncached&quot;] = self.accountingItems.get(&quot;fb-uncached&quot;, 0) + 1
-
-            caching = False
-            if config.EnableFreeBusyCache:
-                # Log extended item
-                if self.logItems is not None:
-                    self.logItems[&quot;fb-uncached&quot;] = self.logItems.get(&quot;fb-uncached&quot;, 0) + 1
-
-                # We want to cache a large range of time based on the current date
-                cache_start = normalizeToUTC(DateTime.getToday() + Duration(days=0 - config.FreeBusyCacheDaysBack))
-                cache_end = normalizeToUTC(DateTime.getToday() + Duration(days=config.FreeBusyCacheDaysForward))
-
-                # If the requested time range would fit in our allowed cache range, trigger the cache creation
-                if compareDateTime(self.timerange.getStart(), cache_start) &gt;= 0 and compareDateTime(self.timerange.getEnd(), cache_end) &lt;= 0:
-                    cache_timerange = Period(cache_start, cache_end)
-                    caching = True
-
-            #
-            # What we do is a fake calendar-query for VEVENT/VFREEBUSYs in the specified time-range.
-            # We then take those results and merge them into one VFREEBUSY component
-            # with appropriate FREEBUSY properties, and return that single item as iCal data.
-            #
-
-            # Create fake filter element to match time-range
-            tr = TimeRange(
-                start=(cache_timerange if caching else self.timerange).getStart().getText(),
-                end=(cache_timerange if caching else self.timerange).getEnd().getText(),
-            )
-            filter = caldavxml.Filter(
-                caldavxml.ComponentFilter(
-                    caldavxml.ComponentFilter(
-                        tr,
-                        name=(&quot;VEVENT&quot;, &quot;VFREEBUSY&quot;, &quot;VAVAILABILITY&quot;),
-                    ),
-                    name=&quot;VCALENDAR&quot;,
-                )
-            )
-            filter = Filter(filter)
-            tzinfo = filter.settimezone(tz)
-            if self.accountingItems is not None:
-                self.accountingItems[&quot;fb-query-timerange&quot;] = (str(tr.start), str(tr.end),)
-
-            try:
-                resources = yield calresource.search(filter, useruid=attendee_uid, fbtype=True)
-                if caching:
-                    yield FBCacheEntry.makeCacheEntry(calresource, attendee_uid, cache_timerange, resources)
-            except IndexedSearchException:
-                raise InternalDataStoreError(&quot;Invalid indexedSearch query&quot;)
-
-        else:
-            if self.accountingItems is not None:
-                self.accountingItems[&quot;fb-cached&quot;] = self.accountingItems.get(&quot;fb-cached&quot;, 0) + 1
-
-            # Log extended item
-            if self.logItems is not None:
-                self.logItems[&quot;fb-cached&quot;] = self.logItems.get(&quot;fb-cached&quot;, 0) + 1
-
-            # Determine appropriate timezone (UTC is the default)
-            tzinfo = tz.gettimezone() if tz is not None else Timezone(utc=True)
-
</del><span class="cx">         # We care about separate instances for VEVENTs only
</span><span class="cx">         aggregated_resources = {}
</span><del>-        for name, uid, type, test_organizer, float, start, end, fbtype, transp in resources:
</del><ins>+        for calid, name, uid, type, test_organizer, float, start, end, fbtype, transp in resources:
</ins><span class="cx">             if transp == 'T' and fbtype != '?':
</span><span class="cx">                 fbtype = 'F'
</span><del>-            aggregated_resources.setdefault((name, uid, type, test_organizer,), []).append((float, start, end, fbtype,))
</del><ins>+            aggregated_resources.setdefault((calid, name, uid, type, test_organizer,), []).append((float, start, end, fbtype,))
</ins><span class="cx"> 
</span><span class="cx">         if self.accountingItems is not None:
</span><span class="cx">             self.accountingItems[&quot;fb-resources&quot;] = {}
</span><span class="cx">             for k, v in aggregated_resources.items():
</span><del>-                name, uid, type, test_organizer = k
</del><ins>+                calid, name, uid, type, test_organizer = k
</ins><span class="cx">                 self.accountingItems[&quot;fb-resources&quot;][uid] = []
</span><span class="cx">                 for float, start, end, fbtype in v:
</span><span class="cx">                     fbstart = parseSQLTimestampToPyCalendar(start)
</span><span class="cx">                     if float == 'Y':
</span><del>-                        fbstart.setTimezone(tzinfo)
</del><ins>+                        fbstart.setTimezone(tzinfos[calid])
</ins><span class="cx">                     else:
</span><span class="cx">                         fbstart.setTimezone(Timezone(utc=True))
</span><span class="cx">                     fbend = parseSQLTimestampToPyCalendar(end)
</span><span class="cx">                     if float == 'Y':
</span><del>-                        fbend.setTimezone(tzinfo)
</del><ins>+                        fbend.setTimezone(tzinfos[calid])
</ins><span class="cx">                     else:
</span><span class="cx">                         fbend.setTimezone(Timezone(utc=True))
</span><span class="cx">                     self.accountingItems[&quot;fb-resources&quot;][uid].append((
</span><span class="lines">@@ -472,7 +422,9 @@
</span><span class="cx">         recordUIDCache = {}
</span><span class="cx">         for key in aggregated_resources.iterkeys():
</span><span class="cx"> 
</span><del>-            name, uid, type, test_organizer = key
</del><ins>+            calid, name, uid, type, test_organizer = key
+            calresource = calidmap[calid]
+            tzinfo = tzinfos[calid]
</ins><span class="cx"> 
</span><span class="cx">             # Short-cut - if an fbtype exists we can use that
</span><span class="cx">             if type == &quot;VEVENT&quot; and aggregated_resources[key][0][3] != '?':
</span><span class="lines">@@ -486,25 +438,9 @@
</span><span class="cx">                         continue
</span><span class="cx"> 
</span><span class="cx">                     # Ignore ones of this UID
</span><del>-                    if self.excludeuid:
-                        # See if we have a UID match
-                        if (self.excludeuid == uid):
-                            if test_organizer:
-                                test_uid = recordUIDCache.get(test_organizer)
-                                if test_uid is None:
-                                    test_record = (yield calresource.directoryService().recordWithCalendarUserAddress(test_organizer))
-                                    test_uid = test_record.uid if test_record else &quot;&quot;
-                                    recordUIDCache[test_organizer] = test_uid
-                            else:
-                                test_uid = &quot;&quot;
</del><ins>+                    if (yield self._testIgnoreExcludeUID(uid, test_organizer, recordUIDCache, directoryService)):
+                        continue
</ins><span class="cx"> 
</span><del>-                            # Check that ORGANIZER's match (security requirement)
-                            if (self.organizer is None) or (organizer_uid == test_uid):
-                                continue
-                            # Check for no ORGANIZER and check by same calendar user
-                            elif (test_uid == &quot;&quot;) and self.same_calendar_user:
-                                continue
-
</del><span class="cx">                     # Apply a timezone to any floating times
</span><span class="cx">                     fbstart = parseSQLTimestampToPyCalendar(start)
</span><span class="cx">                     if float == 'Y':
</span><span class="lines">@@ -532,12 +468,12 @@
</span><span class="cx">                         raise QueryMaxResources(config.MaxQueryWithDataResults, matchtotal)
</span><span class="cx"> 
</span><span class="cx">                     # Add extended details
</span><del>-                    if do_event_details:
</del><ins>+                    if any(self.rich_options.values()):
</ins><span class="cx">                         child = (yield calresource.calendarObjectWithName(name))
</span><span class="cx">                         # Only add fully public events
</span><span class="cx">                         if not child.accessMode or child.accessMode == Component.ACCESS_PUBLIC:
</span><span class="cx">                             calendar = (yield child.componentForUser())
</span><del>-                            self._addEventDetails(calendar, rich_options, tzinfo)
</del><ins>+                            self._addEventDetails(calendar, self.rich_options, tzinfo)
</ins><span class="cx"> 
</span><span class="cx">             else:
</span><span class="cx">                 child = (yield calresource.calendarObjectWithName(name))
</span><span class="lines">@@ -551,26 +487,9 @@
</span><span class="cx">                     continue
</span><span class="cx"> 
</span><span class="cx">                 # Ignore ones of this UID
</span><del>-                if self.excludeuid:
-                    # See if we have a UID match
-                    if (self.excludeuid == uid):
-                        test_organizer = calendar.getOrganizer()
-                        if test_organizer:
-                            test_uid = recordUIDCache.get(test_organizer)
-                            if test_uid is None:
-                                test_record = (yield calresource.directoryService().recordWithCalendarUserAddress(test_organizer))
-                                test_uid = test_record.uid if test_record else &quot;&quot;
-                                recordUIDCache[test_organizer] = test_uid
-                        else:
-                            test_uid = &quot;&quot;
</del><ins>+                if (yield self._testIgnoreExcludeUID(uid, calendar.getOrganizer(), recordUIDCache, calresource.directoryService())):
+                    continue
</ins><span class="cx"> 
</span><del>-                        # Check that ORGANIZER's match (security requirement)
-                        if (self.organizer is None) or (organizer_uid == test_uid):
-                            continue
-                        # Check for no ORGANIZER and check by same calendar user
-                        elif (test_organizer is None) and self.same_calendar_user:
-                            continue
-
</del><span class="cx">                 if self.accountingItems is not None:
</span><span class="cx">                     self.accountingItems.setdefault(&quot;fb-filter-match&quot;, []).append(uid)
</span><span class="cx"> 
</span><span class="lines">@@ -593,16 +512,146 @@
</span><span class="cx">                         assert &quot;Free-busy query returned unwanted component: %s in %r&quot;, (name, calresource,)
</span><span class="cx"> 
</span><span class="cx">                     # Add extended details
</span><del>-                    if calendar.mainType() == &quot;VEVENT&quot; and do_event_details:
-                        child = (yield calresource.calendarObjectWithName(name))
</del><ins>+                    if calendar.mainType() == &quot;VEVENT&quot; and any(self.rich_options.values()):
</ins><span class="cx">                         # Only add fully public events
</span><span class="cx">                         if not child.accessMode or child.accessMode == Component.ACCESS_PUBLIC:
</span><del>-                            calendar = (yield child.componentForUser())
-                            self._addEventDetails(calendar, rich_options, tzinfo)
</del><ins>+                            self._addEventDetails(calendar, self.rich_options, tzinfo)
</ins><span class="cx"> 
</span><span class="cx">         returnValue(matchtotal)
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+    @inlineCallbacks
+    def _matchResources(self, fbset):
+        &quot;&quot;&quot;
+        For now iterate over each calendar and collect the results. In the longer term we might want to consider
+        doing a single DB query in the case where multiple calendars need to be searched.
+
+        @param fbset: list of calendars to process
+        @type fbset: L{list} of L{Calendar}
+        &quot;&quot;&quot;
+
+        results = []
+        tzinfos = {}
+        for calresource in fbset:
+            resources, tzinfo = yield self._matchCalendarResources(calresource)
+            results.extend([(calresource.id(),) + tuple(resource) for resource in resources])
+            tzinfos[calresource.id()] = tzinfo
+
+        returnValue((results, tzinfos,))
+
+
+    @inlineCallbacks
+    def _matchCalendarResources(self, calresource):
+
+        # Get the timezone property from the collection.
+        tz = calresource.getTimezone()
+
+        # Try cache
+        resources = (yield FBCacheEntry.getCacheEntry(calresource, self.attendee_uid, self.timerange)) if config.EnableFreeBusyCache else None
+
+        if resources is None:
+
+            if self.accountingItems is not None:
+                self.accountingItems[&quot;fb-uncached&quot;] = self.accountingItems.get(&quot;fb-uncached&quot;, 0) + 1
+
+            caching = False
+            if config.EnableFreeBusyCache:
+                # Log extended item
+                if self.logItems is not None:
+                    self.logItems[&quot;fb-uncached&quot;] = self.logItems.get(&quot;fb-uncached&quot;, 0) + 1
+
+                # We want to cache a large range of time based on the current date
+                cache_start = normalizeToUTC(DateTime.getToday() + Duration(days=0 - config.FreeBusyCacheDaysBack))
+                cache_end = normalizeToUTC(DateTime.getToday() + Duration(days=config.FreeBusyCacheDaysForward))
+
+                # If the requested time range would fit in our allowed cache range, trigger the cache creation
+                if compareDateTime(self.timerange.getStart(), cache_start) &gt;= 0 and compareDateTime(self.timerange.getEnd(), cache_end) &lt;= 0:
+                    cache_timerange = Period(cache_start, cache_end)
+                    caching = True
+
+            #
+            # What we do is a fake calendar-query for VEVENT/VFREEBUSYs in the specified time-range.
+            # We then take those results and merge them into one VFREEBUSY component
+            # with appropriate FREEBUSY properties, and return that single item as iCal data.
+            #
+
+            # Create fake filter element to match time-range
+            tr = TimeRange(
+                start=(cache_timerange if caching else self.timerange).getStart().getText(),
+                end=(cache_timerange if caching else self.timerange).getEnd().getText(),
+            )
+            filter = caldavxml.Filter(
+                caldavxml.ComponentFilter(
+                    caldavxml.ComponentFilter(
+                        tr,
+                        name=(&quot;VEVENT&quot;, &quot;VFREEBUSY&quot;, &quot;VAVAILABILITY&quot;),
+                    ),
+                    name=&quot;VCALENDAR&quot;,
+                )
+            )
+            filter = Filter(filter)
+            tzinfo = filter.settimezone(tz)
+            if self.accountingItems is not None:
+                self.accountingItems[&quot;fb-query-timerange&quot;] = (str(tr.start), str(tr.end),)
+
+            try:
+                resources = yield calresource.search(filter, useruid=self.attendee_uid, fbtype=True)
+                if caching:
+                    yield FBCacheEntry.makeCacheEntry(calresource, self.attendee_uid, cache_timerange, resources)
+            except IndexedSearchException:
+                raise InternalDataStoreError(&quot;Invalid indexedSearch query&quot;)
+
+        else:
+            if self.accountingItems is not None:
+                self.accountingItems[&quot;fb-cached&quot;] = self.accountingItems.get(&quot;fb-cached&quot;, 0) + 1
+
+            # Log extended item
+            if self.logItems is not None:
+                self.logItems[&quot;fb-cached&quot;] = self.logItems.get(&quot;fb-cached&quot;, 0) + 1
+
+            # Determine appropriate timezone (UTC is the default)
+            tzinfo = tz.gettimezone() if tz is not None else Timezone(utc=True)
+
+        returnValue((resources, tzinfo,))
+
+
+    @inlineCallbacks
+    def _testIgnoreExcludeUID(self, uid, test_organizer, recordUIDCache, dirservice):
+        &quot;&quot;&quot;
+        Check whether the event with the specified UID can be correctly excluded from the
+        freebusy result.
+
+        @param uid: UID to test
+        @type uid: L{str}
+        @param test_organizer: organizer cu-address of the event
+        @type test_organizer: L{str}
+        @param recordUIDCache: cache of directory records
+        @type recordUIDCache: L{dict}
+        @param dirservice: directory service to use for record lookups
+        @type dirservice: L{DirectoryService}
+        &quot;&quot;&quot;
+
+        # See if we have a UID match
+        if self.excludeuid == uid:
+            if test_organizer:
+                test_uid = recordUIDCache.get(test_organizer)
+                if test_uid is None:
+                    test_record = (yield dirservice.recordWithCalendarUserAddress(test_organizer))
+                    test_uid = test_record.uid if test_record else &quot;&quot;
+                    recordUIDCache[test_organizer] = test_uid
+            else:
+                test_uid = &quot;&quot;
+
+            # Check that ORGANIZER's match (security requirement)
+            if (self.organizer is None) or (self.organizer_uid == test_uid):
+                returnValue(True)
+            # Check for no ORGANIZER and check by same calendar user
+            elif (test_uid == &quot;&quot;) and self.same_calendar_user:
+                returnValue(True)
+
+        returnValue(False)
+
+
</ins><span class="cx">     def _addEventDetails(self, calendar, rich_options, tzinfo):
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         Expand events within the specified time range and limit the set of properties to those allowed for
</span></span></pre></div>
<a id="CalendarServertrunktxdavcaldavdatastoreschedulingprocessingpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/caldav/datastore/scheduling/processing.py (14687 => 14688)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/caldav/datastore/scheduling/processing.py        2015-04-17 21:05:17 UTC (rev 14687)
+++ CalendarServer/trunk/txdav/caldav/datastore/scheduling/processing.py        2015-04-20 18:00:40 UTC (rev 14688)
</span><span class="lines">@@ -801,7 +801,7 @@
</span><span class="cx">         uid = calendar.resourceUID()
</span><span class="cx"> 
</span><span class="cx">         # Object to do freebusy query
</span><del>-        freebusy = FreebusyQuery(None, None, None, None, None, None, uid, None, accountingItems=accounting if len(instances) == 1 else None)
</del><ins>+        freebusy = FreebusyQuery(recipient=self.recipient, excludeUID=uid, accountingItems=accounting if len(instances) == 1 else None)
</ins><span class="cx"> 
</span><span class="cx">         # Now compare each instance time-range with the index and see if there is an overlap
</span><span class="cx">         fbset = (yield self.recipient.inbox.ownerHome().loadCalendars())
</span><span class="lines">@@ -844,7 +844,7 @@
</span><span class="cx">                         )
</span><span class="cx"> 
</span><span class="cx">                         freebusy.timerange = tr
</span><del>-                        yield freebusy.generateFreeBusyInfo(testcal, fbinfo, 0)
</del><ins>+                        yield freebusy.generateFreeBusyInfo([testcal, ], fbinfo)
</ins><span class="cx"> 
</span><span class="cx">                         # If any fbinfo entries exist we have an overlap
</span><span class="cx">                         if len(fbinfo.busy) or len(fbinfo.tentative) or len(fbinfo.unavailable):
</span></span></pre></div>
<a id="CalendarServertrunktxdavcaldavdatastoreschedulingtesttest_freebusypy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/caldav/datastore/scheduling/test/test_freebusy.py (14687 => 14688)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/caldav/datastore/scheduling/test/test_freebusy.py        2015-04-17 21:05:17 UTC (rev 14687)
+++ CalendarServer/trunk/txdav/caldav/datastore/scheduling/test/test_freebusy.py        2015-04-20 18:00:40 UTC (rev 14688)
</span><span class="lines">@@ -61,7 +61,7 @@
</span><span class="cx"> &quot;&quot;&quot;,
</span><span class="cx">             ),
</span><span class="cx">             (
</span><del>-                &quot;#1.2 No busy time with organizer &amp; attendee&quot;,
</del><ins>+                &quot;#1.2 No busy time with organizerProp &amp; attendeeProp&quot;,
</ins><span class="cx">                 FreebusyQuery.FBInfo([], [], []),
</span><span class="cx">                 Period.parseText(&quot;20080601T000000Z/20080602T000000Z&quot;),
</span><span class="cx">                 Property(&quot;ORGANIZER&quot;, &quot;mailto:user01@example.com&quot;),
</span><span class="lines">@@ -230,8 +230,8 @@
</span><span class="cx">             ),
</span><span class="cx">         )
</span><span class="cx"> 
</span><del>-        for description, fbinfo, timerange, organizer, attendee, event_details, calendar in data:
-            freebusy = FreebusyQuery(None, organizer, None, attendee, None, timerange, None, None, event_details=event_details)
</del><ins>+        for description, fbinfo, timerange, organizerProp, attendeeProp, event_details, calendar in data:
+            freebusy = FreebusyQuery(organizerProp=organizerProp, attendeeProp=attendeeProp, timerange=timerange, event_details=event_details)
</ins><span class="cx">             result = freebusy.buildFreeBusyResult(fbinfo)
</span><span class="cx">             self.assertEqual(normalizeiCalendarText(str(result)), calendar.replace(&quot;\n&quot;, &quot;\r\n&quot;), msg=description)
</span><span class="cx"> 
</span><span class="lines">@@ -313,11 +313,11 @@
</span><span class="cx"> 
</span><span class="cx">         calendar = (yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar_1&quot;))
</span><span class="cx">         fbinfo = FreebusyQuery.FBInfo([], [], [])
</span><del>-        matchtotal = 0
</del><span class="cx">         timerange = Period(self.now, self.now_1D)
</span><span class="cx"> 
</span><del>-        freebusy = FreebusyQuery(None, None, None, None, None, timerange, None, None)
-        result = (yield freebusy.generateFreeBusyInfo(calendar, fbinfo, matchtotal))
</del><ins>+        organizer = recipient = yield calendarUserFromCalendarUserAddress(&quot;mailto:user01@example.com&quot;, self.transactionUnderTest())
+        freebusy = FreebusyQuery(organizer=organizer, recipient=recipient, timerange=timerange)
+        result = (yield freebusy.generateFreeBusyInfo([calendar, ], fbinfo))
</ins><span class="cx">         self.assertEqual(result, 0)
</span><span class="cx">         self.assertEqual(len(fbinfo.busy), 0)
</span><span class="cx">         self.assertEqual(len(fbinfo.tentative), 0)
</span><span class="lines">@@ -345,11 +345,11 @@
</span><span class="cx">         yield self._createCalendarObject(data, &quot;user01&quot;, &quot;test.ics&quot;)
</span><span class="cx">         calendar = (yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar_1&quot;))
</span><span class="cx">         fbinfo = FreebusyQuery.FBInfo([], [], [])
</span><del>-        matchtotal = 0
</del><span class="cx">         timerange = Period(self.now, self.now_1D)
</span><span class="cx"> 
</span><del>-        freebusy = FreebusyQuery(None, None, None, None, None, timerange, None, None)
-        result = (yield freebusy.generateFreeBusyInfo(calendar, fbinfo, matchtotal))
</del><ins>+        organizer = recipient = yield calendarUserFromCalendarUserAddress(&quot;mailto:user01@example.com&quot;, self.transactionUnderTest())
+        freebusy = FreebusyQuery(organizer=organizer, recipient=recipient, timerange=timerange)
+        result = (yield freebusy.generateFreeBusyInfo([calendar, ], fbinfo))
</ins><span class="cx">         self.assertEqual(result, 1)
</span><span class="cx">         self.assertEqual(fbinfo.busy, [Period.parseText(&quot;%s/%s&quot; % (self.now_12H.getText(), self.now_13H.getText(),)), ])
</span><span class="cx">         self.assertEqual(len(fbinfo.tentative), 0)
</span><span class="lines">@@ -377,19 +377,13 @@
</span><span class="cx">         yield self._createCalendarObject(data, &quot;user01&quot;, &quot;test.ics&quot;)
</span><span class="cx">         calendar = (yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar_1&quot;))
</span><span class="cx">         fbinfo = FreebusyQuery.FBInfo([], [], [])
</span><del>-        matchtotal = 0
</del><span class="cx">         timerange = Period(self.now, self.now_1D)
</span><span class="cx">         event_details = []
</span><span class="cx"> 
</span><del>-        organizer = recipient = (yield calendarUserFromCalendarUserAddress(&quot;mailto:user01@example.com&quot;, self.transactionUnderTest()))
-
-        freebusy = FreebusyQuery(organizer, None, recipient, None, None, timerange, None, None, event_details=event_details)
</del><ins>+        organizer = recipient = yield calendarUserFromCalendarUserAddress(&quot;mailto:user01@example.com&quot;, self.transactionUnderTest())
+        freebusy = FreebusyQuery(organizer=organizer, recipient=recipient, timerange=timerange, event_details=event_details)
</ins><span class="cx">         freebusy.same_calendar_user = True
</span><del>-        result = (yield freebusy.generateFreeBusyInfo(
-            calendar,
-            fbinfo,
-            matchtotal,
-        ))
</del><ins>+        result = yield freebusy.generateFreeBusyInfo([calendar, ], fbinfo)
</ins><span class="cx">         self.assertEqual(result, 1)
</span><span class="cx">         self.assertEqual(fbinfo.busy, [Period(self.now_12H, self.now_13H), ])
</span><span class="cx">         self.assertEqual(len(fbinfo.tentative), 0)
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastorepoddingstore_apipy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/podding/store_api.py (14687 => 14688)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/podding/store_api.py        2015-04-17 21:05:17 UTC (rev 14687)
+++ CalendarServer/trunk/txdav/common/datastore/podding/store_api.py        2015-04-20 18:00:40 UTC (rev 14688)
</span><span class="lines">@@ -85,7 +85,7 @@
</span><span class="cx">         txn, request, server = yield self._getRequestForStoreObject(&quot;freebusy&quot;, calresource, False)
</span><span class="cx"> 
</span><span class="cx">         request[&quot;organizer&quot;] = organizer
</span><del>-        request[&quot;recipient&quot;] = organizer
</del><ins>+        request[&quot;recipient&quot;] = recipient
</ins><span class="cx">         request[&quot;timerange&quot;] = timerange.getText()
</span><span class="cx">         request[&quot;matchtotal&quot;] = matchtotal
</span><span class="cx">         request[&quot;excludeuid&quot;] = excludeuid
</span><span class="lines">@@ -107,17 +107,21 @@
</span><span class="cx">         # Operate on the L{CommonHomeChild}
</span><span class="cx">         calresource, _ignore = yield self._getStoreObjectForRequest(txn, request)
</span><span class="cx"> 
</span><del>-        organizer = yield calendarUserFromCalendarUserAddress(request[&quot;organizer&quot;], txn)
-        recipient = yield calendarUserFromCalendarUserAddress(request[&quot;recipient&quot;], txn)
</del><ins>+        organizer = yield calendarUserFromCalendarUserAddress(request[&quot;organizer&quot;], txn) if request[&quot;organizer&quot;] else None
+        recipient = yield calendarUserFromCalendarUserAddress(request[&quot;recipient&quot;], txn) if request[&quot;recipient&quot;] else None
</ins><span class="cx"> 
</span><span class="cx">         freebusy = FreebusyQuery(
</span><del>-            organizer, None, recipient, None, None,
-            Period.parseText(request[&quot;timerange&quot;]), request[&quot;excludeuid&quot;], None, event_details=request[&quot;event_details&quot;])
</del><ins>+            organizer=organizer,
+            recipient=recipient,
+            timerange=Period.parseText(request[&quot;timerange&quot;]),
+            excludeUID=request[&quot;excludeuid&quot;],
+            event_details=request[&quot;event_details&quot;],
+        )
</ins><span class="cx">         fbinfo = FreebusyQuery.FBInfo([], [], [])
</span><span class="cx">         matchtotal = yield freebusy.generateFreeBusyInfo(
</span><del>-            calresource,
</del><ins>+            [calresource, ],
</ins><span class="cx">             fbinfo,
</span><del>-            request[&quot;matchtotal&quot;],
</del><ins>+            matchtotal=request[&quot;matchtotal&quot;],
</ins><span class="cx">         )
</span><span class="cx"> 
</span><span class="cx">         # Convert L{Period} objects to text for JSON response
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastorepoddingtesttest_conduitpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/podding/test/test_conduit.py (14687 => 14688)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/podding/test/test_conduit.py        2015-04-17 21:05:17 UTC (rev 14687)
+++ CalendarServer/trunk/txdav/common/datastore/podding/test/test_conduit.py        2015-04-20 18:00:40 UTC (rev 14688)
</span><span class="lines">@@ -931,8 +931,8 @@
</span><span class="cx">         timerange = Period(DateTime.parseText(fbstart), DateTime.parseText(fbend))
</span><span class="cx">         organizer = recipient = (yield calendarUserFromCalendarUserAddress(&quot;mailto:puser01@example.com&quot;, self.theTransactionUnderTest(1)))
</span><span class="cx"> 
</span><del>-        freebusy = FreebusyQuery(organizer, None, recipient, None, None, timerange, None, None)
-        matchtotal = (yield freebusy.generateFreeBusyInfo(shared, fbinfo, 0))
</del><ins>+        freebusy = FreebusyQuery(organizer=organizer, recipient=recipient, timerange=timerange)
+        matchtotal = (yield freebusy.generateFreeBusyInfo([shared, ], fbinfo))
</ins><span class="cx"> 
</span><span class="cx">         self.assertEqual(matchtotal, 1)
</span><span class="cx">         self.assertEqual(fbinfo[0], [Period.parseText(&quot;{now:04d}0102T140000Z/PT1H&quot;.format(**self.nowYear)), ])
</span></span></pre>
</div>
</div>

</body>
</html>