Permalink
Browse files

[PubSub] added ServiceHelper#delete_item_from(node, id) to delete ite…

…ms published to persistent nodes
  • Loading branch information...
1 parent 5aa246a commit 9c34317cfbae4dc65526b84c53751109b6f1a0ca Pradeep Elankumaran committed Oct 28, 2008
Showing with 42 additions and 0 deletions.
  1. +25 −0 lib/xmpp4r/pubsub/children/retract.rb
  2. +17 −0 lib/xmpp4r/pubsub/helper/servicehelper.rb
@@ -0,0 +1,25 @@
+# =XMPP4R - XMPP Library for Ruby
+# License:: Ruby's license (see the LICENSE file) or GNU GPL, at your option.
+# Website::http://home.gna.org/xmpp4r/
+
+require 'xmpp4r/xmppelement'
+
+module Jabber
+ module PubSub
+
+ ##
+ # Retract
+ #
+ # A <retract> XMPP element, see example 103 in
+ # http://xmpp.org/extensions/xep-0060.html#publisher-delete
+ class Retract < XMPPElement
+ name_xmlns 'retract', NS_PUBSUB
+ ##
+ # return the node for this publication
+ def node
+ attributes['node']
+ end
+ end
+ end
+end
+
@@ -188,6 +188,23 @@ def publish_item_with_id_to(node,item,id)
end
##
+ # deletes an item from a persistent node
+ # node:: [String]
+ # id:: [String]
+ # return:: true
+ def delete_item_from(node, item_id)
+ iq = basic_pubsub_query(:set)
+ retract = iq.pubsub.add(REXML::Element.new('retract'))
+ retract.attributes['node'] = node
+
+ xmlitem = Jabber::PubSub::Item.new
+ xmlitem.id = item_id
+ retract.add(xmlitem)
+ @stream.send_with_id(iq)
+ end
+
+
+ ##
# purges all items on a persistent node
# node:: [String]
# return:: true

0 comments on commit 9c34317

Please sign in to comment.