diff sat/plugins/plugin_xep_0060.py @ 3312:77177b13ff54

plugin XEP-0060: serialise psItemsGet result with data_format
author Goffi <goffi@goffi.org>
date Fri, 17 Jul 2020 12:57:23 +0200
parents 384283adcce1
children 23af257ae780
line wrap: on
line diff
--- a/sat/plugins/plugin_xep_0060.py	Thu Jul 16 09:07:26 2020 +0200
+++ b/sat/plugins/plugin_xep_0060.py	Fri Jul 17 12:57:23 2020 +0200
@@ -190,7 +190,7 @@
             "psItemsGet",
             ".plugin",
             in_sign="ssiassa{ss}s",
-            out_sign="(asa{ss})",
+            out_sign="s",
             method=self._getItems,
             async_=True,
         )
@@ -599,6 +599,11 @@
             raise exceptions.DataError("Can't find Item in MAM message element")
         return item_elt
 
+    def serialiseItems(self, items_data):
+        items, metadata = items_data
+        metadata['items'] = items
+        return data_format.serialise(metadata)
+
     def _getItems(self, service="", node="", max_items=10, item_ids=None, sub_id=None,
                   extra_dict=None, profile_key=C.PROF_KEY_NONE):
         """Get items from pubsub node
@@ -620,6 +625,7 @@
             extra.extra,
         )
         d.addCallback(self.transItemsData)
+        d.addCallback(self.serialiseItems)
         return d
 
     def getItems(self, client, service, node, max_items=None, item_ids=None, sub_id=None,