diff sat/memory/memory.py @ 3170:39d7327583e1

core: use serialised dict for `extra` in messageNew and historyGet
author Goffi <goffi@goffi.org>
date Tue, 18 Feb 2020 18:13:17 +0100
parents d10b2368684e
children ae09989e9feb
line wrap: on
line diff
--- a/sat/memory/memory.py	Fri Feb 14 15:18:52 2020 +0100
+++ b/sat/memory/memory.py	Tue Feb 18 18:13:17 2020 +0100
@@ -590,10 +590,19 @@
     def addToHistory(self, client, data):
         return self.storage.addToHistory(data, client.profile)
 
+    def _historyGetSerialise(self, history_data):
+        return [
+            (uid, timestamp, from_jid, to_jid, message, subject, mess_type,
+             data_format.serialise(extra)) for uid, timestamp, from_jid, to_jid, message,
+            subject, mess_type, extra in history_data
+        ]
+
     def _historyGet(self, from_jid_s, to_jid_s, limit=C.HISTORY_LIMIT_NONE, between=True,
                     filters=None, profile=C.PROF_KEY_NONE):
-        return self.historyGet(jid.JID(from_jid_s), jid.JID(to_jid_s), limit, between,
+        d = self.historyGet(jid.JID(from_jid_s), jid.JID(to_jid_s), limit, between,
                                filters, profile)
+        d.addCallback(self._historyGetSerialise)
+        return d
 
     def historyGet(self, from_jid, to_jid, limit=C.HISTORY_LIMIT_NONE, between=True,
                    filters=None, profile=C.PROF_KEY_NONE):