comparison 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
comparison
equal deleted inserted replaced
342:28c9579901d3 343:ff8aff4c9b79
1173 if subscription is None: 1173 if subscription is None:
1174 notifications = yield self.backend.getNotifications(node, items_data) 1174 notifications = yield self.backend.getNotifications(node, items_data)
1175 else: 1175 else:
1176 notifications = [(subscription.subscriber, [subscription], items_data)] 1176 notifications = [(subscription.subscriber, [subscription], items_data)]
1177 1177
1178 if pep and node.getConfiguration()[const.OPT_ACCESS_MODEL] in ('open', 'presence'):
1179 # for PEP we need to manage automatic subscriptions (cf. XEP-0163 §4)
1180 explicit_subscribers = {subscriber for subscriber, _, _ in notifications}
1181 auto_subscribers = yield self.backend.privilege.getAutoSubscribers(recipient, node.nodeIdentifier, explicit_subscribers)
1182 for sub_jid in auto_subscribers:
1183 sub = pubsub.Subscription(node.nodeIdentifier, sub_jid, 'subscribed')
1184 notifications.append((sub_jid, [sub], items_data))
1185
1178 owners = yield node.getOwners() 1186 owners = yield node.getOwners()
1179 owner_roster = None 1187 owner_roster = None
1180 1188
1181 # now we check access of subscriber for each item, and keep only allowed ones 1189 # now we check access of subscriber for each item, and keep only allowed ones
1182 1190