diff sat_pubsub/backend.py @ 343:ff8aff4c9b79

backend, psql: implemented notifications for auto subscribers in PEP: people with presence permission from node owner and who request notification (+notify) from node will receive notifications according to XEP-0163 §4. This make SàT Pubsub a nearly fully compliant PEP service. Following features are still missing: - presence access model, should be implemented very soon as everything is already there - deleting resource on unavailable presence, will be implemented really soon - XEP-0115 hash check - and most importantly, rosters updates. XEP-0356 needs to be updated for this.
author Goffi <goffi@goffi.org>
date Sun, 20 Aug 2017 18:41:21 +0200
parents b49f75a26156
children 3bbab2173ebc
line wrap: on
line diff
--- a/sat_pubsub/backend.py	Sun Aug 20 12:35:04 2017 +0200
+++ b/sat_pubsub/backend.py	Sun Aug 20 18:41:21 2017 +0200
@@ -1175,6 +1175,14 @@
         else:
             notifications = [(subscription.subscriber, [subscription], items_data)]
 
+        if pep and node.getConfiguration()[const.OPT_ACCESS_MODEL] in ('open', 'presence'):
+            # for PEP we need to manage automatic subscriptions (cf. XEP-0163 §4)
+            explicit_subscribers = {subscriber for subscriber, _, _ in notifications}
+            auto_subscribers = yield self.backend.privilege.getAutoSubscribers(recipient, node.nodeIdentifier, explicit_subscribers)
+            for sub_jid in auto_subscribers:
+                 sub = pubsub.Subscription(node.nodeIdentifier, sub_jid, 'subscribed')
+                 notifications.append((sub_jid, [sub], items_data))
+
         owners = yield node.getOwners()
         owner_roster = None