<!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>[15561] CalendarServer/trunk/txdav</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/15561">15561</a></dd>
<dt>Author</dt> <dd>cdaboo@apple.com</dd>
<dt>Date</dt> <dd>2016-04-28 10:26:17 -0700 (Thu, 28 Apr 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>Need category/priority in cross-pod push notifications.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#CalendarServertrunktxdavcaldavdatastoretesttest_sql_externalpy">CalendarServer/trunk/txdav/caldav/datastore/test/test_sql_external.py</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastorepoddingsharing_invitespy">CalendarServer/trunk/txdav/common/datastore/podding/sharing_invites.py</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoresqlpy">CalendarServer/trunk/txdav/common/datastore/sql.py</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoresql_externalpy">CalendarServer/trunk/txdav/common/datastore/sql_external.py</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoresql_sharingpy">CalendarServer/trunk/txdav/common/datastore/sql_sharing.py</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="CalendarServertrunktxdavcaldavdatastoretesttest_sql_externalpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/caldav/datastore/test/test_sql_external.py (15560 => 15561)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/caldav/datastore/test/test_sql_external.py        2016-04-28 15:01:12 UTC (rev 15560)
+++ CalendarServer/trunk/txdav/caldav/datastore/test/test_sql_external.py        2016-04-28 17:26:17 UTC (rev 15561)
</span><span class="lines">@@ -15,18 +15,24 @@
</span><span class="cx"> ##
</span><span class="cx">
</span><span class="cx">
</span><ins>+from calendarserver.push.ipush import PushPriority
+
+from operator import methodcaller
+
+from twext.python.clsprop import classproperty
+
</ins><span class="cx"> from twisted.internet.defer import inlineCallbacks
</span><span class="cx">
</span><del>-from twext.python.clsprop import classproperty
-from txdav.common.datastore.test.util import populateCalendarsFrom
</del><ins>+from twistedcaldav.ical import Component
+
+from txdav.common.datastore.podding.base import FailedCrossPodRequestError
+from txdav.common.datastore.podding.test.util import MultiStoreConduitTest
</ins><span class="cx"> from txdav.common.datastore.sql_tables import _BIND_MODE_READ, \
</span><span class="cx"> _BIND_STATUS_INVITED, _BIND_MODE_DIRECT, _BIND_STATUS_ACCEPTED, \
</span><span class="cx"> _HOME_STATUS_EXTERNAL, _BIND_MODE_WRITE
</span><del>-from txdav.common.datastore.podding.test.util import MultiStoreConduitTest
-from txdav.common.datastore.podding.base import FailedCrossPodRequestError
</del><ins>+from txdav.common.datastore.test.util import populateCalendarsFrom
</ins><span class="cx"> from txdav.common.icommondatastore import ExternalShareFailed
</span><del>-from twistedcaldav.ical import Component
-from operator import methodcaller, itemgetter
</del><ins>+from txdav.idav import ChangeCategory
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> class BaseSharingTests(MultiStoreConduitTest):
</span><span class="lines">@@ -762,17 +768,19 @@
</span><span class="cx">
</span><span class="cx"> map(methodcaller("reset"), self.theNotifiers)
</span><span class="cx">
</span><ins>+ def _checkNotifications(priority=PushPriority.high):
+ self.assertEqual(set(self.theNotifiers[0].history), set([("/CalDAV/example.com/user01/", priority), ("/CalDAV/example.com/user01/calendar/", priority)]))
+ self.assertEqual(set(self.theNotifiers[1].history), set([("/CalDAV/example.com/user01/", priority), ("/CalDAV/example.com/user01/calendar/", priority)]))
+ map(methodcaller("reset"), self.theNotifiers)
+
</ins><span class="cx"> # Change by owner
</span><span class="cx"> home = yield self.homeUnderTest(txn=self.theTransactionUnderTest(0), name="user01")
</span><span class="cx"> self.assertEquals(home.notifierID(), ("CalDAV", "user01",))
</span><span class="cx"> calendar = yield home.calendarWithName("calendar")
</span><span class="cx"> yield calendar.createObjectResourceWithName("2.ics", Component.fromString(self.cal2))
</span><span class="cx"> yield self.commitTransaction(0)
</span><ins>+ _checkNotifications()
</ins><span class="cx">
</span><del>- self.assertEqual(set(map(itemgetter(0), self.theNotifiers[0].history)), set(["/CalDAV/example.com/user01/", "/CalDAV/example.com/user01/calendar/"]))
- self.assertEqual(set(map(itemgetter(0), self.theNotifiers[1].history)), set(["/CalDAV/example.com/user01/", "/CalDAV/example.com/user01/calendar/"]))
- map(methodcaller("reset"), self.theNotifiers)
-
</del><span class="cx"> # Change by sharee on other pod
</span><span class="cx"> txn2 = self.theTransactionUnderTest(1)
</span><span class="cx"> home = yield self.homeUnderTest(txn=txn2, name="puser02")
</span><span class="lines">@@ -781,11 +789,8 @@
</span><span class="cx"> cobj = yield calendar.calendarObjectWithName("2.ics")
</span><span class="cx"> yield cobj.remove()
</span><span class="cx"> yield self.commitTransaction(1)
</span><ins>+ _checkNotifications()
</ins><span class="cx">
</span><del>- self.assertEqual(set(map(itemgetter(0), self.theNotifiers[0].history)), set(["/CalDAV/example.com/user01/", "/CalDAV/example.com/user01/calendar/"]))
- self.assertEqual(set(map(itemgetter(0), self.theNotifiers[1].history)), set(["/CalDAV/example.com/user01/", "/CalDAV/example.com/user01/calendar/"]))
- map(methodcaller("reset"), self.theNotifiers)
-
</del><span class="cx"> # Change by sharee on same pod
</span><span class="cx"> txn2 = self.theTransactionUnderTest(0)
</span><span class="cx"> home = yield self.homeUnderTest(txn=txn2, name="user02")
</span><span class="lines">@@ -793,10 +798,15 @@
</span><span class="cx"> calendar = yield home.calendarWithName(shared_name_user02)
</span><span class="cx"> yield calendar.createObjectResourceWithName("2_1.ics", Component.fromString(self.cal2))
</span><span class="cx"> yield self.commitTransaction(0)
</span><ins>+ _checkNotifications()
</ins><span class="cx">
</span><del>- self.assertEqual(set(map(itemgetter(0), self.theNotifiers[0].history)), set(["/CalDAV/example.com/user01/", "/CalDAV/example.com/user01/calendar/"]))
- self.assertEqual(set(map(itemgetter(0), self.theNotifiers[1].history)), set(["/CalDAV/example.com/user01/", "/CalDAV/example.com/user01/calendar/"]))
- map(methodcaller("reset"), self.theNotifiers)
</del><ins>+ # Different priority for owner change
+ home = yield self.homeUnderTest(txn=self.theTransactionUnderTest(0), name="user01")
+ self.assertEquals(home.notifierID(), ("CalDAV", "user01",))
+ calendar = yield home.calendarWithName("calendar")
+ yield calendar.notifyChanged(category=ChangeCategory.attendeeITIPUpdate)
+ yield self.commitTransaction(0)
+ _checkNotifications(priority=PushPriority.medium)
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx">
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastorepoddingsharing_invitespy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/podding/sharing_invites.py (15560 => 15561)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/podding/sharing_invites.py        2016-04-28 15:01:12 UTC (rev 15560)
+++ CalendarServer/trunk/txdav/common/datastore/podding/sharing_invites.py        2016-04-28 17:26:17 UTC (rev 15561)
</span><span class="lines">@@ -18,6 +18,7 @@
</span><span class="cx">
</span><span class="cx"> from txdav.common.datastore.podding.base import FailedCrossPodRequestError
</span><span class="cx"> from txdav.common.datastore.sql_tables import _HOME_STATUS_EXTERNAL
</span><ins>+from txdav.idav import ChangeCategory
</ins><span class="cx"> from twext.python.log import Logger
</span><span class="cx">
</span><span class="cx"> log = Logger()
</span><span class="lines">@@ -247,7 +248,7 @@
</span><span class="cx"> @inlineCallbacks
</span><span class="cx"> def send_sharenotification(
</span><span class="cx"> self, txn, homeType, ownerUID,
</span><del>- bindUID, shareeUIDs,
</del><ins>+ bindUID, shareeUIDs, category,
</ins><span class="cx"> ):
</span><span class="cx"> """
</span><span class="cx"> Send a sharing notification cross-pod message for the specified sharees. Note that we
</span><span class="lines">@@ -264,6 +265,9 @@
</span><span class="cx">
</span><span class="cx"> @param shareeUIDs: UIDs of the sharees
</span><span class="cx"> @type shareeUIDs: C{str}
</span><ins>+
+ @param category: category (priority) of notification
+ @type category: C{ChangeCategory}
</ins><span class="cx"> """
</span><span class="cx">
</span><span class="cx"> recipients = {}
</span><span class="lines">@@ -278,6 +282,7 @@
</span><span class="cx"> "type": homeType,
</span><span class="cx"> "ownerUID": ownerUID,
</span><span class="cx"> "bindUID": bindUID,
</span><ins>+ "category": category.name,
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> deferreds = []
</span><span class="lines">@@ -313,5 +318,11 @@
</span><span class="cx"> if ownerCalendar is None:
</span><span class="cx"> returnValue(None)
</span><span class="cx">
</span><ins>+ # Extract category - use default if unknown
+ try:
+ category = ChangeCategory.lookupByName(request["category"])
+ except ValueError:
+ category = ChangeCategory.default
+
</ins><span class="cx"> # Send the notification
</span><del>- yield ownerCalendar.notifyChanged()
</del><ins>+ yield ownerCalendar.notifyChanged(category=category)
</ins></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoresqlpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/sql.py (15560 => 15561)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/sql.py        2016-04-28 15:01:12 UTC (rev 15560)
+++ CalendarServer/trunk/txdav/common/datastore/sql.py        2016-04-28 17:26:17 UTC (rev 15561)
</span><span class="lines">@@ -4508,7 +4508,7 @@
</span><span class="cx"> yield notifier.notify(self._txn, priority=category.value)
</span><span class="cx">
</span><span class="cx"> if not self.external():
</span><del>- yield self.notifyExternalShare()
</del><ins>+ yield self.notifyExternalShare(category)
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> @classproperty
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoresql_externalpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/sql_external.py (15560 => 15561)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/sql_external.py        2016-04-28 15:01:12 UTC (rev 15560)
+++ CalendarServer/trunk/txdav/common/datastore/sql_external.py        2016-04-28 17:26:17 UTC (rev 15561)
</span><span class="lines">@@ -30,6 +30,7 @@
</span><span class="cx"> from txdav.common.datastore.sql_tables import _HOME_STATUS_EXTERNAL
</span><span class="cx"> from txdav.common.icommondatastore import NonExistentExternalShare, \
</span><span class="cx"> ExternalShareFailed
</span><ins>+from txdav.idav import ChangeCategory
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> log = Logger()
</span><span class="lines">@@ -203,7 +204,7 @@
</span><span class="cx"> raise AssertionError("CommonHomeExternal: not supported")
</span><span class="cx">
</span><span class="cx">
</span><del>- def notifyChanged(self):
</del><ins>+ def notifyChanged(self, category=ChangeCategory.default):
</ins><span class="cx"> """
</span><span class="cx"> Notifications are not handled for external homes - make this a no-op.
</span><span class="cx"> """
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoresql_sharingpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/sql_sharing.py (15560 => 15561)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/sql_sharing.py        2016-04-28 15:01:12 UTC (rev 15560)
+++ CalendarServer/trunk/txdav/common/datastore/sql_sharing.py        2016-04-28 17:26:17 UTC (rev 15561)
</span><span class="lines">@@ -32,6 +32,7 @@
</span><span class="cx"> _HOME_STATUS_EXTERNAL, _HOME_STATUS_DISABLED
</span><span class="cx"> from txdav.common.icommondatastore import ExternalShareFailed, \
</span><span class="cx"> HomeChildNameAlreadyExistsError, AllRetriesFailed
</span><ins>+from txdav.idav import ChangeCategory
</ins><span class="cx"> from txdav.xml import element
</span><span class="cx">
</span><span class="cx"> from uuid import uuid4
</span><span class="lines">@@ -580,7 +581,7 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> @inlineCallbacks
</span><del>- def notifyExternalShare(self):
</del><ins>+ def notifyExternalShare(self, category=ChangeCategory.default):
</ins><span class="cx"> """
</span><span class="cx"> Send a cross-pod message to all external shares to ensure change notifications are sent
</span><span class="cx"> to external sharees' clients subscribed to notifications on the other pods.
</span><span class="lines">@@ -608,6 +609,7 @@
</span><span class="cx"> self.ownerHome().uid(),
</span><span class="cx"> ownerView.bindUID(),
</span><span class="cx"> externalUIDs,
</span><ins>+ category,
</ins><span class="cx"> )
</span><span class="cx">
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>