mirror of
https://github.com/correl/SleekXMPP.git
synced 2024-11-23 19:19:53 +00:00
Add support for notify attribute when retracting an item.
This commit is contained in:
parent
d7fc2aaa9c
commit
7e5e9542e9
3 changed files with 42 additions and 5 deletions
|
@ -317,7 +317,7 @@ class xep_0060(base_plugin):
|
|||
iq['pubsub']['publish_options'] = options
|
||||
return iq.send(block=block, callback=callback, timeout=timeout)
|
||||
|
||||
def retract(self, jid, node, id, ifrom=None, block=True,
|
||||
def retract(self, jid, node, id, notify=None, ifrom=None, block=True,
|
||||
callback=None, timeout=None):
|
||||
"""
|
||||
Delete a single item from a node.
|
||||
|
@ -325,6 +325,7 @@ class xep_0060(base_plugin):
|
|||
iq = self.xmpp.Iq(sto=jid, sfrom=ifrom, stype='set')
|
||||
|
||||
iq['pubsub']['retract']['node'] = node
|
||||
iq['pubsub']['retract']['notify'] = notify
|
||||
iq['pubsub']['retract']['item']['id'] = id
|
||||
return iq.send(block=block, callback=callback, timeout=timeout)
|
||||
|
||||
|
|
|
@ -129,6 +129,23 @@ class Retract(ElementBase):
|
|||
plugin_attrib = name
|
||||
interfaces = set(('node', 'notify'))
|
||||
|
||||
def get_notify(self):
|
||||
notify = self._get_attr('notify')
|
||||
if notify in ('0', 'false'):
|
||||
return False
|
||||
elif notify in ('1', 'true'):
|
||||
return True
|
||||
return None
|
||||
|
||||
def set_notify(self, value):
|
||||
del self['notify']
|
||||
if value is None:
|
||||
return
|
||||
elif value in (True, '1', 'true', 'True'):
|
||||
self._set_attr('notify', 'true')
|
||||
else:
|
||||
self._set_attr('notify', 'false')
|
||||
|
||||
|
||||
class Unsubscribe(ElementBase):
|
||||
namespace = 'http://jabber.org/protocol/pubsub'
|
||||
|
@ -252,6 +269,11 @@ class PubsubStateEvent(ElementBase):
|
|||
intefaces = set(tuple())
|
||||
|
||||
|
||||
register_stanza_plugin(Iq, PubsubState)
|
||||
register_stanza_plugin(Message, PubsubStateEvent)
|
||||
register_stanza_plugin(PubsubStateEvent, PubsubState)
|
||||
|
||||
|
||||
register_stanza_plugin(Iq, Pubsub)
|
||||
register_stanza_plugin(Pubsub, Affiliations)
|
||||
register_stanza_plugin(Pubsub, Configure)
|
||||
|
@ -274,7 +296,3 @@ register_stanza_plugin(Retract, Item)
|
|||
register_stanza_plugin(Subscribe, Options)
|
||||
register_stanza_plugin(Subscription, SubscribeOptions)
|
||||
register_stanza_plugin(Subscriptions, Subscription, iterable=True)
|
||||
|
||||
register_stanza_plugin(Message, PubsubStateEvent)
|
||||
register_stanza_plugin(Iq, PubsubState)
|
||||
register_stanza_plugin(PubsubStateEvent, PubsubState)
|
||||
|
|
|
@ -478,6 +478,24 @@ class TestStreamPubsub(SleekTest):
|
|||
</iq>
|
||||
""", use_values=False)
|
||||
|
||||
def testRetract(self):
|
||||
"""Test deleting an item."""
|
||||
self.xmpp['xep_0060'].retract(
|
||||
'pubsub.example.com',
|
||||
'somenode',
|
||||
'ID1',
|
||||
notify=True,
|
||||
block=False)
|
||||
self.send("""
|
||||
<iq type="set" id="1" to="pubsub.example.com">
|
||||
<pubsub xmlns="http://jabber.org/protocol/pubsub">
|
||||
<retract node="somenode" notify="true">
|
||||
<item id="ID1" />
|
||||
</retract>
|
||||
</pubsub>
|
||||
</iq>
|
||||
""")
|
||||
|
||||
def testRetract(self):
|
||||
"""Test deleting an item."""
|
||||
self.xmpp['xep_0060'].retract(
|
||||
|
|
Loading…
Reference in a new issue