From abbd14484b2b4371059ea582b7ae0f66c73f7694 Mon Sep 17 00:00:00 2001 From: Goffi Date: Mon, 18 May 2020 23:38:21 +0200 Subject: [PATCH] plugin XEP-0060: fixed payload parsing in sendItem --- sat/plugins/plugin_xep_0060.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sat/plugins/plugin_xep_0060.py b/sat/plugins/plugin_xep_0060.py index 8f25b450..f5b08378 100644 --- a/sat/plugins/plugin_xep_0060.py +++ b/sat/plugins/plugin_xep_0060.py @@ -453,6 +453,7 @@ class XEP_0060(object): 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 @@ class XEP_0060(object): 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 @@ class XEP_0060(object): @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