Mercurial > libervia-backend
comparison src/plugins/plugin_xep_0060.py @ 2389:5675af905725
plugin XEP-0060: added createIfNewNode method which doesn't fail in case of conflict.
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 20 Oct 2017 08:44:09 +0200 |
parents | 72cbb6478f97 |
children | 8ed4ac10cb5e |
comparison
equal
deleted
inserted
replaced
2388:4c883d1c3e81 | 2389:5675af905725 |
---|---|
445 @param option(dict[unicode, unicode], None): node configuration options | 445 @param option(dict[unicode, unicode], None): node configuration options |
446 @return (unicode): identifier of the created node (may be different from requested name) | 446 @return (unicode): identifier of the created node (may be different from requested name) |
447 """ | 447 """ |
448 return client.pubsub_client.createNode(service, nodeIdentifier, options) | 448 return client.pubsub_client.createNode(service, nodeIdentifier, options) |
449 | 449 |
450 @defer.inlineCallbacks | |
451 def createIfNewNode(self, client, service, nodeIdentifier, options=None): | |
452 """Helper method similar to createNode, but will not fail in case of conflict""" | |
453 try: | |
454 yield self.createNode(client, service, nodeIdentifier, options) | |
455 except error.StanzaError as e: | |
456 if e.condition == 'conflict': | |
457 pass | |
458 else: | |
459 raise e | |
460 | |
450 def _getNodeConfiguration(self, service_s, nodeIdentifier, profile_key): | 461 def _getNodeConfiguration(self, service_s, nodeIdentifier, profile_key): |
451 client = self.host.getClient(profile_key) | 462 client = self.host.getClient(profile_key) |
452 d = self.getConfiguration(client, jid.JID(service_s) if service_s else None, nodeIdentifier) | 463 d = self.getConfiguration(client, jid.JID(service_s) if service_s else None, nodeIdentifier) |
453 def serialize(form): | 464 def serialize(form): |
454 # FIXME: better more generic dataform serialisation should be available in SàT | 465 # FIXME: better more generic dataform serialisation should be available in SàT |