changeset 3272:4c98f4972db5

plugin XEP-0060: fixed payload parsing in sendItem
author Goffi <goffi@goffi.org>
date Mon, 18 May 2020 23:38:21 +0200
parents abca25af06d7
children 4230aaeab9a7
files sat/plugins/plugin_xep_0060.py
diffstat 1 files changed, 4 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/sat/plugins/plugin_xep_0060.py	Mon May 18 23:37:04 2020 +0200
+++ b/sat/plugins/plugin_xep_0060.py	Mon May 18 23:38:21 2020 +0200
@@ -453,6 +453,7 @@
                   profile_key=C.PROF_KEY_NONE):
         client = self.host.getClient(profile_key)
         service = None if not service else jid.JID(service)
+        payload = generic.parseXml(payload.encode())
         extra = data_format.deserialise(extra_ser)
         d = self.sendItem(
             client, service, nodeIdentifier, payload, item_id or None, extra
@@ -465,7 +466,7 @@
         client = self.host.getClient(profile_key)
         service = None if not service else jid.JID(service)
         try:
-            items = [generic.parseXml(item.encode('utf-8')) for item in items]
+            items = [generic.parseXml(item.encode()) for item in items]
         except Exception as e:
             raise exceptions.DataError(_("Can't parse items: {msg}").format(
                 msg=e))
@@ -492,11 +493,12 @@
         @param service(jid.JID, None): service to send the item to
             None to use PEP
         @param NodeIdentifier(unicode): PubSub node to use
-        @param payload(domish.Element, unicode): payload of the item to send
+        @param payload(domish.Element): payload of the item to send
         @param item_id(unicode, None): id to use or None to create one
         @param extra(dict, None): extra option, not used yet
         @return (unicode, None): id of the created item
         """
+        assert isinstance(payload, domish.Element)
         item_elt = domish.Element((pubsub.NS_PUBSUB, 'item'))
         if item_id is not None:
             item_elt['id'] = item_id