# HG changeset patch # User Goffi # Date 1589837901 -7200 # Node ID 4c98f4972db5f6cf75cd163deb2d214dab276b25 # Parent abca25af06d75107211ce30071320589a4b40168 plugin XEP-0060: fixed payload parsing in sendItem diff -r abca25af06d7 -r 4c98f4972db5 sat/plugins/plugin_xep_0060.py --- 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