Mercurial > libervia-pubsub
diff sat_pubsub/privilege.py @ 455:0b5233981671
backend: fix `delete` notification + add `purge` notification
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 02 Aug 2021 21:58:17 +0200 |
parents | 96342e7e9f5d |
children | 607616f9ef5b |
line wrap: on
line diff
--- a/sat_pubsub/privilege.py Mon Aug 02 21:56:43 2021 +0200 +++ b/sat_pubsub/privilege.py Mon Aug 02 21:58:17 2021 +0200 @@ -186,39 +186,55 @@ def notifyPublish(self, pep_jid, nodeIdentifier, notifications): """Do notifications using privileges""" for subscriber, subscriptions, items in notifications: - message = self._pubsub_service._createNotification('items', pep_jid, - nodeIdentifier, subscriber, - subscriptions) + message = self._pubsub_service._createNotification( + 'items', + pep_jid, + nodeIdentifier, + subscriber, + subscriptions + ) for item in items: item.uri = pubsub.NS_PUBSUB_EVENT message.event.items.addChild(item) self.sendMessage(message) - def notifyRetract(self, pep_jid, nodeIdentifier, notifications): for subscriber, subscriptions, items in notifications: - message = self._pubsub_service._createNotification('items', pep_jid, - nodeIdentifier, subscriber, - subscriptions) + message = self._pubsub_service._createNotification( + 'items', + pep_jid, + nodeIdentifier, + subscriber, + subscriptions + ) for item in items: retract = domish.Element((None, "retract")) retract['id'] = item['id'] message.event.items.addChild(retract) self.sendMessage(message) + def notifyDelete(self, pep_jid, nodeIdentifier, subscribers, redirectURI=None): + for subscriber in subscribers: + message = self._pubsub_service._createNotification( + 'delete', + pep_jid, + nodeIdentifier, + subscriber + ) + if redirectURI: + redirect = message.event.delete.addElement('redirect') + redirect['uri'] = redirectURI + self.sendMessage(message) - # def notifyDelete(self, service, nodeIdentifier, subscribers, - # redirectURI=None): - # # TODO - # for subscriber in subscribers: - # message = self._createNotification('delete', service, - # nodeIdentifier, - # subscriber) - # if redirectURI: - # redirect = message.event.delete.addElement('redirect') - # redirect['uri'] = redirectURI - # self.send(message) - + def notifyPurge(self, pep_jid, nodeIdentifier, subscribers): + for subscriber in subscribers: + message = self._pubsub_service._createNotification( + 'purge', + pep_jid, + nodeIdentifier, + subscriber + ) + self.sendMessage(message) ## presence ##