# HG changeset patch # User Goffi # Date 1550265223 -3600 # Node ID ae127e14b0405bb93b4b5050951abdf7acce280b # Parent 3b68293a60d4b3e92ca787679bc4bf61b64c6e12 plugin XEP-0060: added purgeNode/psNodePurge method to remove all items from a node diff -r 3b68293a60d4 -r ae127e14b040 sat/plugins/plugin_xep_0060.py --- a/sat/plugins/plugin_xep_0060.py Fri Feb 15 22:13:20 2019 +0100 +++ b/sat/plugins/plugin_xep_0060.py Fri Feb 15 22:13:43 2019 +0100 @@ -144,6 +144,14 @@ async=True, ) host.bridge.addMethod( + "psNodePurge", + ".plugin", + in_sign="sss", + out_sign="", + method=self._purgeNode, + async=True, + ) + host.bridge.addMethod( "psNodeDelete", ".plugin", in_sign="sss", @@ -905,6 +913,15 @@ d = request.send(client.xmlstream) return d + def _purgeNode(self, service_s, nodeIdentifier, profile_key): + client = self.host.getClient(profile_key) + return self.purgeNode( + client, jid.JID(service_s) if service_s else None, nodeIdentifier + ) + + def purgeNode(self, client, service, nodeIdentifier): + return client.pubsub_client.purgeNode(service, nodeIdentifier) + def _deleteNode(self, service_s, nodeIdentifier, profile_key): client = self.host.getClient(profile_key) return self.deleteNode( @@ -1443,6 +1460,19 @@ return d.addCallback(cb) + def purgeNode(self, service, nodeIdentifier): + """Purge a node (i.e. delete all items from it) + + @param service(jid.JID, None): service to send the item to + None to use PEP + @param NodeIdentifier(unicode): PubSub node to use + """ + # TODO: propose this upstream and remove it once merged + request = pubsub.PubSubRequest('purge') + request.recipient = service + request.nodeIdentifier = nodeIdentifier + return request.send(self.xmlstream) + def getDiscoInfo(self, requestor, service, nodeIdentifier=""): disco_info = [] self.host.trigger.point("PubSub Disco Info", disco_info, self.parent.profile)