[CalendarServer-changes] [15561] CalendarServer/trunk/txdav

source_changes at macosforge.org source_changes at macosforge.org
Thu Apr 28 10:26:18 PDT 2016


Revision: 15561
          http://trac.calendarserver.org//changeset/15561
Author:   cdaboo at apple.com
Date:     2016-04-28 10:26:17 -0700 (Thu, 28 Apr 2016)
Log Message:
-----------
Need category/priority in cross-pod push notifications.

Modified Paths:
--------------
    CalendarServer/trunk/txdav/caldav/datastore/test/test_sql_external.py
    CalendarServer/trunk/txdav/common/datastore/podding/sharing_invites.py
    CalendarServer/trunk/txdav/common/datastore/sql.py
    CalendarServer/trunk/txdav/common/datastore/sql_external.py
    CalendarServer/trunk/txdav/common/datastore/sql_sharing.py

Modified: CalendarServer/trunk/txdav/caldav/datastore/test/test_sql_external.py
===================================================================
--- 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)
@@ -15,18 +15,24 @@
 ##
 
 
+from calendarserver.push.ipush import PushPriority
+
+from operator import methodcaller
+
+from twext.python.clsprop import classproperty
+
 from twisted.internet.defer import inlineCallbacks
 
-from twext.python.clsprop import classproperty
-from txdav.common.datastore.test.util import populateCalendarsFrom
+from twistedcaldav.ical import Component
+
+from txdav.common.datastore.podding.base import FailedCrossPodRequestError
+from txdav.common.datastore.podding.test.util import MultiStoreConduitTest
 from txdav.common.datastore.sql_tables import _BIND_MODE_READ, \
     _BIND_STATUS_INVITED, _BIND_MODE_DIRECT, _BIND_STATUS_ACCEPTED, \
     _HOME_STATUS_EXTERNAL, _BIND_MODE_WRITE
-from txdav.common.datastore.podding.test.util import MultiStoreConduitTest
-from txdav.common.datastore.podding.base import FailedCrossPodRequestError
+from txdav.common.datastore.test.util import populateCalendarsFrom
 from txdav.common.icommondatastore import ExternalShareFailed
-from twistedcaldav.ical import Component
-from operator import methodcaller, itemgetter
+from txdav.idav import ChangeCategory
 
 
 class BaseSharingTests(MultiStoreConduitTest):
@@ -762,17 +768,19 @@
 
         map(methodcaller("reset"), self.theNotifiers)
 
+        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)
+
         # Change by owner
         home = yield self.homeUnderTest(txn=self.theTransactionUnderTest(0), name="user01")
         self.assertEquals(home.notifierID(), ("CalDAV", "user01",))
         calendar = yield home.calendarWithName("calendar")
         yield calendar.createObjectResourceWithName("2.ics", Component.fromString(self.cal2))
         yield self.commitTransaction(0)
+        _checkNotifications()
 
-        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)
-
         # Change by sharee on other pod
         txn2 = self.theTransactionUnderTest(1)
         home = yield self.homeUnderTest(txn=txn2, name="puser02")
@@ -781,11 +789,8 @@
         cobj = yield calendar.calendarObjectWithName("2.ics")
         yield cobj.remove()
         yield self.commitTransaction(1)
+        _checkNotifications()
 
-        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)
-
         # Change by sharee on same pod
         txn2 = self.theTransactionUnderTest(0)
         home = yield self.homeUnderTest(txn=txn2, name="user02")
@@ -793,10 +798,15 @@
         calendar = yield home.calendarWithName(shared_name_user02)
         yield calendar.createObjectResourceWithName("2_1.ics", Component.fromString(self.cal2))
         yield self.commitTransaction(0)
+        _checkNotifications()
 
-        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)
+        # 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)
 
 
 

Modified: CalendarServer/trunk/txdav/common/datastore/podding/sharing_invites.py
===================================================================
--- 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)
@@ -18,6 +18,7 @@
 
 from txdav.common.datastore.podding.base import FailedCrossPodRequestError
 from txdav.common.datastore.sql_tables import _HOME_STATUS_EXTERNAL
+from txdav.idav import ChangeCategory
 from twext.python.log import Logger
 
 log = Logger()
@@ -247,7 +248,7 @@
     @inlineCallbacks
     def send_sharenotification(
         self, txn, homeType, ownerUID,
-        bindUID, shareeUIDs,
+        bindUID, shareeUIDs, category,
     ):
         """
         Send a sharing notification cross-pod message for the specified sharees. Note that we
@@ -264,6 +265,9 @@
 
         @param shareeUIDs: UIDs of the sharees
         @type shareeUIDs: C{str}
+
+        @param category: category (priority) of notification
+        @type category: C{ChangeCategory}
         """
 
         recipients = {}
@@ -278,6 +282,7 @@
             "type": homeType,
             "ownerUID": ownerUID,
             "bindUID": bindUID,
+            "category": category.name,
         }
 
         deferreds = []
@@ -313,5 +318,11 @@
         if ownerCalendar is None:
             returnValue(None)
 
+        # Extract category - use default if unknown
+        try:
+            category = ChangeCategory.lookupByName(request["category"])
+        except ValueError:
+            category = ChangeCategory.default
+
         # Send the notification
-        yield ownerCalendar.notifyChanged()
+        yield ownerCalendar.notifyChanged(category=category)

Modified: CalendarServer/trunk/txdav/common/datastore/sql.py
===================================================================
--- 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)
@@ -4508,7 +4508,7 @@
                 yield notifier.notify(self._txn, priority=category.value)
 
         if not self.external():
-            yield self.notifyExternalShare()
+            yield self.notifyExternalShare(category)
 
 
     @classproperty

Modified: CalendarServer/trunk/txdav/common/datastore/sql_external.py
===================================================================
--- 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)
@@ -30,6 +30,7 @@
 from txdav.common.datastore.sql_tables import _HOME_STATUS_EXTERNAL
 from txdav.common.icommondatastore import NonExistentExternalShare, \
     ExternalShareFailed
+from txdav.idav import ChangeCategory
 
 
 log = Logger()
@@ -203,7 +204,7 @@
         raise AssertionError("CommonHomeExternal: not supported")
 
 
-    def notifyChanged(self):
+    def notifyChanged(self, category=ChangeCategory.default):
         """
         Notifications are not handled for external homes - make this a no-op.
         """

Modified: CalendarServer/trunk/txdav/common/datastore/sql_sharing.py
===================================================================
--- 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)
@@ -32,6 +32,7 @@
     _HOME_STATUS_EXTERNAL, _HOME_STATUS_DISABLED
 from txdav.common.icommondatastore import ExternalShareFailed, \
     HomeChildNameAlreadyExistsError, AllRetriesFailed
+from txdav.idav import ChangeCategory
 from txdav.xml import element
 
 from uuid import uuid4
@@ -580,7 +581,7 @@
 
 
     @inlineCallbacks
-    def notifyExternalShare(self):
+    def notifyExternalShare(self, category=ChangeCategory.default):
         """
         Send a cross-pod message to all external shares to ensure change notifications are sent
         to external sharees' clients subscribed to notifications on the other pods.
@@ -608,6 +609,7 @@
                 self.ownerHome().uid(),
                 ownerView.bindUID(),
                 externalUIDs,
+                category,
             )
 
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20160428/a9173a85/attachment-0001.html>


More information about the calendarserver-changes mailing list