Mercurial > libervia-pubsub
changeset 355:c72fcbdcdab7
backend: fixed subscription, PEP was not handled correctly
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 08 Sep 2017 08:02:05 +0200 |
parents | 18b983fe9e1b |
children | 95c83899b5e9 |
files | sat_pubsub/backend.py |
diffstat | 1 files changed, 13 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/sat_pubsub/backend.py Fri Sep 08 08:02:05 2017 +0200 +++ b/sat_pubsub/backend.py Fri Sep 08 08:02:05 2017 +0200 @@ -460,11 +460,10 @@ d = self.storage.getNode(nodeIdentifier, pep, recipient) d.addCallback(_getAffiliation, subscriberEntity) - d.addCallback(self._doSubscribe, subscriber) + d.addCallback(self._doSubscribe, subscriber, pep, recipient) return d - def _doSubscribe(self, result, subscriber): - # TODO: implement other access models + def _doSubscribe(self, result, subscriber, pep, recipient): node, affiliation = result if affiliation == 'outcast': @@ -490,22 +489,24 @@ def cb(sendLast): d = node.getSubscription(subscriber) if sendLast: - d.addCallback(self._sendLastPublished, node) + d.addCallback(self._sendLastPublished, node, pep, recipient) return d - d = node.addSubscription(subscriber, 'subscribed', {}) + d.addCallback(lambda _: node.addSubscription(subscriber, 'subscribed', {})) d.addCallbacks(lambda _: True, trapExists) d.addCallback(cb) return d - def _sendLastPublished(self, subscription, node): + def _sendLastPublished(self, subscription, node, pep, recipient): - def notifyItem(items): - if items: + def notifyItem(items_data): + if items_data: reactor.callLater(0, self.dispatch, - {'items': items, + {'items_data': items_data, 'node': node, + 'pep': pep, + 'recipient': recipient, 'subscription': subscription, }, '//event/pubsub/notify') @@ -515,7 +516,7 @@ 'never') if sendLastPublished == 'on_sub' and node.nodeType == 'leaf': entity = subscription.subscriber.userhostJID() - d = self.getItems(node.nodeIdentifier, entity, 1) + d = self.getItemsData(node.nodeIdentifier, entity, recipient, maxItems=1, ext_data={'pep': pep}) d.addCallback(notifyItem) d.addErrback(log.err) @@ -529,8 +530,8 @@ d.addCallback(lambda node: node.removeSubscription(subscriber)) return d - def getSubscriptions(self, entity): - return self.storage.getSubscriptions(entity) + def getSubscriptions(self, requestor, pep, recipient): + return self.storage.getSubscriptions(requestor, pep, recipient) def supportsAutoCreate(self): return True