comparison sat/core/xmpp.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 b5c058c7692e
children dcebc585c29f
comparison
equal deleted inserted replaced
3169:560642ab1c10 3170:39d7327583e1
1 #!/usr/bin/env python3 1 #!/usr/bin/env python3
2 2
3 3 # SàT: a XMPP client
4 # SAT: a jabber client
5 # Copyright (C) 2009-2020 Jérôme Poisson (goffi@goffi.org) 4 # Copyright (C) 2009-2020 Jérôme Poisson (goffi@goffi.org)
6 5
7 # This program is free software: you can redistribute it and/or modify 6 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU Affero General Public License as published by 7 # it under the terms of the GNU Affero General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or 8 # the Free Software Foundation, either version 3 of the License, or
40 from sat.core.log import getLogger 39 from sat.core.log import getLogger
41 from sat.core import exceptions 40 from sat.core import exceptions
42 from sat.memory import encryption 41 from sat.memory import encryption
43 from sat.memory import persistent 42 from sat.memory import persistent
44 from sat.tools import xml_tools 43 from sat.tools import xml_tools
44 from sat.tools.common import data_format
45 from zope.interface import implementer 45 from zope.interface import implementer
46 46
47 log = getLogger(__name__) 47 log = getLogger(__name__)
48 48
49 49
675 675
676 def messageGetBridgeArgs(self, data): 676 def messageGetBridgeArgs(self, data):
677 """Generate args to use with bridge from data dict""" 677 """Generate args to use with bridge from data dict"""
678 return (data["uid"], data["timestamp"], data["from"].full(), 678 return (data["uid"], data["timestamp"], data["from"].full(),
679 data["to"].full(), data["message"], data["subject"], 679 data["to"].full(), data["message"], data["subject"],
680 data["type"], data["extra"]) 680 data["type"], data_format.serialise(data["extra"]))
681 681
682 682
683 def messageSendToBridge(self, data): 683 def messageSendToBridge(self, data):
684 """Send message to bridge, so frontends can display it 684 """Send message to bridge, so frontends can display it
685 685
858 from_jid=self.jid.full(), 858 from_jid=self.jid.full(),
859 to_jid=to_jid.full(), 859 to_jid=to_jid.full(),
860 message={"": message}, 860 message={"": message},
861 subject={}, 861 subject={},
862 mess_type=C.MESS_TYPE_INFO, 862 mess_type=C.MESS_TYPE_INFO,
863 extra=extra, 863 extra=data_format.serialise(extra),
864 profile=self.profile, 864 profile=self.profile,
865 ) 865 )
866 866
867 def _finish_connection(self, __): 867 def _finish_connection(self, __):
868 d = self.roster.requestRoster() 868 d = self.roster.requestRoster()
1145 data["from"].full(), 1145 data["from"].full(),
1146 data["to"].full(), 1146 data["to"].full(),
1147 data["message"], 1147 data["message"],
1148 data["subject"], 1148 data["subject"],
1149 data["type"], 1149 data["type"],
1150 data["extra"], 1150 data_format.serialise(data["extra"]),
1151 profile=self.parent.profile, 1151 profile=self.parent.profile,
1152 ) 1152 )
1153 else: 1153 else:
1154 log.debug("Discarding bridge signal for empty message: {data}".format( 1154 log.debug("Discarding bridge signal for empty message: {data}".format(
1155 data=data)) 1155 data=data))