Mercurial > libervia-pubsub
diff src/backend.py @ 381:7c490bb60847
backend: items ids are returned in payload if not specified on publish
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 13 Jan 2019 18:56:19 +0100 |
parents | e81964db3cd6 |
children | aa3a464df605 |
line wrap: on
line diff
--- a/src/backend.py Sun Jan 13 18:56:17 2019 +0100 +++ b/src/backend.py Sun Jan 13 18:56:19 2019 +0100 @@ -70,7 +70,7 @@ from twisted.internet import defer, reactor from twisted.words.protocols.jabber.error import StanzaError # from twisted.words.protocols.jabber.jid import JID, InvalidFormat -from twisted.words.xish import utility +from twisted.words.xish import domish, utility from wokkel import disco from wokkel import data_form @@ -380,6 +380,7 @@ items_data = [] check_overwrite = False + ret_payload = None # payload returned, None or domish.Element for item in items: # we enforce publisher (cf XEP-0060 ยง7.1.2.3) item['publisher'] = requestor.full() @@ -389,6 +390,12 @@ if not item.getAttribute("id"): item["id"] = yield node.getNextId() new_item = True + ret_pubsub_elt = domish.Element((pubsub.NS_PUBSUB, u'pubsub')) + ret_publish_elt = ret_pubsub_elt.addElement(u'publish') + ret_publish_elt[u'node'] = node.nodeIdentifier + ret_item_elt = ret_publish_elt.addElement(u'item') + ret_item_elt["id"] = item[u"id"] + ret_payload = ret_pubsub_elt else: check_overwrite = True new_item = False @@ -410,6 +417,7 @@ yield node.storeItems(items_data, requestor) yield self._doNotify(node, items_data, deliverPayloads, pep, recipient) + defer.returnValue(ret_payload) def _doNotify(self, node, items_data, deliverPayloads, pep, recipient): if items_data and not deliverPayloads: