mirror of
https://github.com/correl/SleekXMPP.git
synced 2024-11-23 19:19:53 +00:00
Retract stanzas are behaving oddly when using stanza values.
This commit is contained in:
parent
a1bbb719e1
commit
b68785e19e
3 changed files with 33 additions and 12 deletions
|
@ -305,11 +305,10 @@ class xep_0060(base_plugin):
|
||||||
item['id'] = id
|
item['id'] = id
|
||||||
item['payload'] = payload
|
item['payload'] = payload
|
||||||
iq['pubsub']['publish'].append(item)
|
iq['pubsub']['publish'].append(item)
|
||||||
if options is not None:
|
|
||||||
iq['pubsub']['publish_options'] = options
|
iq['pubsub']['publish_options'] = options
|
||||||
return iq.send(block=block, callback=callback, timeout=timeout)
|
return iq.send(block=block, callback=callback, timeout=timeout)
|
||||||
|
|
||||||
def retract(self, jid, node, item, ifrom=None, block=True,
|
def retract(self, jid, node, item_id, ifrom=None, block=True,
|
||||||
callback=None, timeout=None):
|
callback=None, timeout=None):
|
||||||
"""
|
"""
|
||||||
Delete a single item from a node.
|
Delete a single item from a node.
|
||||||
|
@ -317,9 +316,7 @@ class xep_0060(base_plugin):
|
||||||
iq = self.xmpp.Iq(sto=jid, sfrom=ifrom, stype='set')
|
iq = self.xmpp.Iq(sto=jid, sfrom=ifrom, stype='set')
|
||||||
|
|
||||||
iq['pubsub']['retract']['node'] = node
|
iq['pubsub']['retract']['node'] = node
|
||||||
item = stanza.pubsub.Item()
|
iq['pubsub']['retract']['item']['id'] = item_id
|
||||||
item['id'] = item
|
|
||||||
iq['pubsub']['retract'].append(item)
|
|
||||||
return iq.send(block=block, callback=callback, timeout=timeout)
|
return iq.send(block=block, callback=callback, timeout=timeout)
|
||||||
|
|
||||||
def purge(self, jid, node, ifrom=None, block=True, callback=None,
|
def purge(self, jid, node, ifrom=None, block=True, callback=None,
|
||||||
|
|
|
@ -151,7 +151,7 @@ class Publish(Items):
|
||||||
|
|
||||||
registerStanzaPlugin(Pubsub, Publish)
|
registerStanzaPlugin(Pubsub, Publish)
|
||||||
|
|
||||||
class Retract(Items):
|
class Retract(ElementBase):
|
||||||
namespace = 'http://jabber.org/protocol/pubsub'
|
namespace = 'http://jabber.org/protocol/pubsub'
|
||||||
name = 'retract'
|
name = 'retract'
|
||||||
plugin_attrib = name
|
plugin_attrib = name
|
||||||
|
@ -160,6 +160,7 @@ class Retract(Items):
|
||||||
plugin_tag_map = {}
|
plugin_tag_map = {}
|
||||||
|
|
||||||
registerStanzaPlugin(Pubsub, Retract)
|
registerStanzaPlugin(Pubsub, Retract)
|
||||||
|
registerStanzaPlugin(Retract, Item)
|
||||||
|
|
||||||
class Unsubscribe(ElementBase):
|
class Unsubscribe(ElementBase):
|
||||||
namespace = 'http://jabber.org/protocol/pubsub'
|
namespace = 'http://jabber.org/protocol/pubsub'
|
||||||
|
@ -253,12 +254,14 @@ class PublishOptions(ElementBase):
|
||||||
|
|
||||||
def get_publish_options(self):
|
def get_publish_options(self):
|
||||||
config = self.xml.find('{jabber:x:data}x')
|
config = self.xml.find('{jabber:x:data}x')
|
||||||
|
if config is None:
|
||||||
|
return None
|
||||||
form = xep_0004.Form(xml=config)
|
form = xep_0004.Form(xml=config)
|
||||||
return form
|
return form
|
||||||
|
|
||||||
def set_publish_options(self, value):
|
def set_publish_options(self, value):
|
||||||
if value is None:
|
if value is None:
|
||||||
del self['publish_options']
|
self.del_publish_options()
|
||||||
else:
|
else:
|
||||||
self.xml.append(value.getXML())
|
self.xml.append(value.getXML())
|
||||||
return self
|
return self
|
||||||
|
@ -267,6 +270,7 @@ class PublishOptions(ElementBase):
|
||||||
config = self.xml.find('{jabber:x:data}x')
|
config = self.xml.find('{jabber:x:data}x')
|
||||||
if config is not None:
|
if config is not None:
|
||||||
self.xml.remove(config)
|
self.xml.remove(config)
|
||||||
|
self.parent().xml.remove(self.xml)
|
||||||
|
|
||||||
registerStanzaPlugin(Pubsub, PublishOptions)
|
registerStanzaPlugin(Pubsub, PublishOptions)
|
||||||
|
|
||||||
|
|
|
@ -430,7 +430,7 @@ class TestStreamPubsub(SleekTest):
|
||||||
value='presence')
|
value='presence')
|
||||||
options['type'] = 'submit'
|
options['type'] = 'submit'
|
||||||
|
|
||||||
t = threading.Thread(name='publish_single',
|
t = threading.Thread(name='publish_single_options',
|
||||||
target=self.xmpp['xep_0060'].publish,
|
target=self.xmpp['xep_0060'].publish,
|
||||||
args=('pubsub.example.com', 'somenode'),
|
args=('pubsub.example.com', 'somenode'),
|
||||||
kwargs={'item_id': 'ID42',
|
kwargs={'item_id': 'ID42',
|
||||||
|
@ -479,7 +479,7 @@ class TestStreamPubsub(SleekTest):
|
||||||
|
|
||||||
register_stanza_plugin(self.xmpp['xep_0060'].stanza.Item, AtomEntry)
|
register_stanza_plugin(self.xmpp['xep_0060'].stanza.Item, AtomEntry)
|
||||||
|
|
||||||
t = threading.Thread(name='publish_single',
|
t = threading.Thread(name='publish_multi',
|
||||||
target=self.xmpp['xep_0060'].publish,
|
target=self.xmpp['xep_0060'].publish,
|
||||||
args=('pubsub.example.com', 'somenode'),
|
args=('pubsub.example.com', 'somenode'),
|
||||||
kwargs={'items': [('ID1', payload1),
|
kwargs={'items': [('ID1', payload1),
|
||||||
|
@ -529,7 +529,7 @@ class TestStreamPubsub(SleekTest):
|
||||||
value='presence')
|
value='presence')
|
||||||
options['type'] = 'submit'
|
options['type'] = 'submit'
|
||||||
|
|
||||||
t = threading.Thread(name='publish_single',
|
t = threading.Thread(name='publish_multi_options',
|
||||||
target=self.xmpp['xep_0060'].publish,
|
target=self.xmpp['xep_0060'].publish,
|
||||||
args=('pubsub.example.com', 'somenode'),
|
args=('pubsub.example.com', 'somenode'),
|
||||||
kwargs={'items': [('ID1', payload1),
|
kwargs={'items': [('ID1', payload1),
|
||||||
|
@ -575,7 +575,27 @@ class TestStreamPubsub(SleekTest):
|
||||||
|
|
||||||
def testRetract(self):
|
def testRetract(self):
|
||||||
"""Test deleting an item."""
|
"""Test deleting an item."""
|
||||||
pass
|
t = threading.Thread(name='retract',
|
||||||
|
target=self.xmpp['xep_0060'].retract,
|
||||||
|
args=('pubsub.example.com', 'somenode', 'ID1'))
|
||||||
|
t.start()
|
||||||
|
|
||||||
|
self.send("""
|
||||||
|
<iq type="set" id="1" to="pubsub.example.com">
|
||||||
|
<pubsub xmlns="http://jabber.org/protocol/pubsub">
|
||||||
|
<retract node="somenode">
|
||||||
|
<item id="ID1" />
|
||||||
|
</retract>
|
||||||
|
</pubsub>
|
||||||
|
</iq>
|
||||||
|
""", use_values=False)
|
||||||
|
|
||||||
|
self.recv("""
|
||||||
|
<iq type="result" id="1"
|
||||||
|
to="tester@localhost" from="pubsub.example.com" />
|
||||||
|
""")
|
||||||
|
|
||||||
|
t.join()
|
||||||
|
|
||||||
def testPurge(self):
|
def testPurge(self):
|
||||||
"""Test removing all items from a node."""
|
"""Test removing all items from a node."""
|
||||||
|
|
Loading…
Reference in a new issue