diff src/plugins/plugin_xep_0060.py @ 745:812dc38c0094

plugins groupblog (xep-0060, xep-0277): added blog item modification/deletion
author souliane <souliane@mailoo.org>
date Tue, 10 Dec 2013 09:02:20 +0100
parents 3c304929af74
children bfabeedbf32e
line wrap: on
line diff
--- a/src/plugins/plugin_xep_0060.py	Mon Dec 09 15:31:07 2013 +0100
+++ b/src/plugins/plugin_xep_0060.py	Tue Dec 10 09:02:20 2013 +0100
@@ -18,9 +18,8 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 from logging import debug, info, error
-
+from wokkel.pubsub import PubSubRequest
 from wokkel import disco, pubsub
-
 from zope.interface import implements
 
 PLUGIN_INFO = {
@@ -119,6 +118,10 @@
         profile, client = self.__getClientNProfile(profile_key, 'delete node')
         return client.deleteNode(service, nodeIdentifier)
 
+    def retractItems(self, service, nodeIdentifier, itemIdentifiers, profile_key='@DEFAULT@'):
+        profile, client = self.__getClientNProfile(profile_key, 'retract items')
+        return client.retractItems(service, nodeIdentifier, itemIdentifiers)
+
     def subscribe(self, service, nodeIdentifier, sub_jid=None, options=None, profile_key='@DEFAULT@'):
         profile, client = self.__getClientNProfile(profile_key, 'subscribe node')
         return client.subscribe(service, nodeIdentifier, sub_jid or client.parent.jid.userhostJID(), options=options)
@@ -135,6 +138,25 @@
     def connectionInitialized(self):
         pubsub.PubSubClient.connectionInitialized(self)
 
+    # XXX: this should be done in wokkel
+    def retractItems(self, service, nodeIdentifier, itemIdentifiers, sender=None):
+        """
+        Retract items from a publish subscribe node.
+
+        @param service: The publish subscribe service to delete the node from.
+        @type service: L{JID<twisted.words.protocols.jabber.jid.JID>}
+        @param nodeIdentifier: The identifier of the node.
+        @type nodeIdentifier: C{unicode}
+        @param itemIdentifiers: Identifiers of the items to be retracted.
+        @type itemIdentifiers: C{set}
+        """
+        request = PubSubRequest('retract')
+        request.recipient = service
+        request.nodeIdentifier = nodeIdentifier
+        request.itemIdentifiers = itemIdentifiers
+        request.sender = sender
+        return request.send(self.xmlstream)
+
     def itemsReceived(self, event):
         if not self.host.trigger.point("PubSubItemsReceived", event, self.parent.profile):
             return