changeset 3392:0957ea9137b8

plugin XEP-0047: fixed file reading and content encoding
author Goffi <goffi@goffi.org>
date Thu, 12 Nov 2020 14:53:15 +0100
parents e898a43b5bea
children 2b6f69f6df8c
files sat/plugins/plugin_xep_0047.py
diffstat 1 files changed, 3 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/sat/plugins/plugin_xep_0047.py	Thu Nov 12 14:53:15 2020 +0100
+++ b/sat/plugins/plugin_xep_0047.py	Thu Nov 12 14:53:15 2020 +0100
@@ -327,7 +327,8 @@
         """
         session_data["timer"].reset(TIMEOUT)
 
-        buffer_ = session_data["stream_object"].read(session_data["block_size"])
+        # FIXME: producer/consumer mechanism is not used properly here
+        buffer_ = session_data["stream_object"].file_obj.read(session_data["block_size"])
         if buffer_:
             next_iq_elt = client.IQ()
             next_iq_elt["from"] = session_data["local_jid"].full()
@@ -336,7 +337,7 @@
             seq = session_data["seq"] = (session_data["seq"] + 1) % 65535
             data_elt["seq"] = str(seq)
             data_elt["sid"] = session_data["id"]
-            data_elt.addContent(base64.b64encode(buffer_))
+            data_elt.addContent(base64.b64encode(buffer_).decode())
             args = [session_data, client]
             d = next_iq_elt.send()
             d.addCallbacks(self._IQDataStreamCb, self._IQDataStreamEb, args, None, args)