Mercurial > libervia-backend
changeset 3179:84a94b385760
bridge: messageSend's extra is now serialised
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 21 Feb 2020 12:17:38 +0100 (2020-02-21) |
parents | 98b321234068 |
children | 826bca181226 |
files | sat/bridge/bridge_constructor/bridge_template.ini sat/bridge/dbus_bridge.py sat/core/sat_main.py sat/core/xmpp.py sat/plugins/plugin_xep_0277.py sat_frontends/jp/cmd_message.py sat_frontends/quick_frontend/quick_app.py |
diffstat | 7 files changed, 16 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/sat/bridge/bridge_constructor/bridge_template.ini Tue Feb 18 18:17:18 2020 +0100 +++ b/sat/bridge/bridge_constructor/bridge_template.ini Fri Feb 21 12:17:38 2020 +0100 @@ -428,7 +428,7 @@ async= type=method category=core -sig_in=sa{ss}a{ss}sa{ss}s +sig_in=sa{ss}a{ss}sss sig_out= param_2_default={} param_3_default="auto" @@ -441,7 +441,7 @@ doc_param_2=subject: Subject of the message key is the language of the subject, use '' when unknown doc_param_3=mess_type: Type of the message (cf RFC 6121 §5.2.2) or "auto" for automatic type detection -doc_param_4=extra: optional data that can be used by a plugin to build more specific messages +doc_param_4=extra: (serialised) optional data that can be used by a plugin to build more specific messages doc_param_5=%(doc_profile_key)s [messageEncryptionStart]
--- a/sat/bridge/dbus_bridge.py Tue Feb 18 18:17:18 2020 +0100 +++ b/sat/bridge/dbus_bridge.py Fri Feb 21 12:17:38 2020 +0100 @@ -457,10 +457,10 @@ return self._callback("messageEncryptionStop", str(to_jid), str(profile_key), callback=callback, errback=errback) @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX, - in_signature='sa{ss}a{ss}sa{ss}s', out_signature='', + in_signature='sa{ss}a{ss}sss', out_signature='', async_callbacks=('callback', 'errback')) def messageSend(self, to_jid, message, subject={}, mess_type="auto", extra={}, profile_key="@NONE@", callback=None, errback=None): - return self._callback("messageSend", str(to_jid), message, subject, str(mess_type), extra, str(profile_key), callback=callback, errback=errback) + return self._callback("messageSend", str(to_jid), message, subject, str(mess_type), str(extra), str(profile_key), callback=callback, errback=errback) @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX, in_signature='', out_signature='a{ss}',
--- a/sat/core/sat_main.py Tue Feb 18 18:17:18 2020 +0100 +++ b/sat/core/sat_main.py Fri Feb 21 12:17:38 2020 +0100 @@ -783,18 +783,17 @@ ## XMPP methods ## - def _messageSend(self, to_jid_s, message, subject=None, mess_type="auto", extra=None, - profile_key=C.PROF_KEY_NONE,): + def _messageSend( + self, to_jid_s, message, subject=None, mess_type="auto", extra_s="", + profile_key=C.PROF_KEY_NONE): client = self.getClient(profile_key) to_jid = jid.JID(to_jid_s) - # XXX: we need to use the dictionary comprehension because D-Bus return its own - # types, and pickle can't manage them. TODO: Need to find a better way return client.sendMessage( to_jid, message, subject, mess_type, - {str(key): str(value) for key, value in list(extra.items())}, + data_format.deserialise(extra_s) ) def _setPresence(self, to="", show="", statuses=None, profile_key=C.PROF_KEY_NONE):
--- a/sat/core/xmpp.py Tue Feb 18 18:17:18 2020 +0100 +++ b/sat/core/xmpp.py Fri Feb 21 12:17:38 2020 +0100 @@ -555,8 +555,9 @@ """ raise NotImplementedError - def sendMessage(self, to_jid, message, subject=None, mess_type="auto", extra=None, - uid=None, no_trigger=False,): + def sendMessage( + self, to_jid, message, subject=None, mess_type="auto", extra=None, uid=None, + no_trigger=False): r"""Send a message to an entity @param to_jid(jid.JID): destinee of the message
--- a/sat/plugins/plugin_xep_0277.py Tue Feb 18 18:17:18 2020 +0100 +++ b/sat/plugins/plugin_xep_0277.py Fri Feb 21 12:17:38 2020 +0100 @@ -1,6 +1,5 @@ #!/usr/bin/env python3 - # SAT plugin for microblogging over XMPP (xep-0277) # Copyright (C) 2009-2020 Jérôme Poisson (goffi@goffi.org) @@ -21,7 +20,6 @@ from sat.core.constants import Const as C from sat.core.log import getLogger -log = getLogger(__name__) from twisted.words.protocols.jabber import jid, error from twisted.words.protocols.jabber.xmlstream import XMPPHandler from twisted.words.xish import domish @@ -44,6 +42,9 @@ import calendar import urllib.parse +log = getLogger(__name__) + + NS_MICROBLOG = "urn:xmpp:microblog:0" NS_ATOM = "http://www.w3.org/2005/Atom" NS_PUBSUB_EVENT = "{}{}".format(pubsub.NS_PUBSUB, "#event")
--- a/sat_frontends/jp/cmd_message.py Tue Feb 18 18:17:18 2020 +0100 +++ b/sat_frontends/jp/cmd_message.py Fri Feb 21 12:17:38 2020 +0100 @@ -142,7 +142,7 @@ msg, subject, self.args.type, - extra, + data_format.serialise(extra), profile_key=self.host.profile) except Exception as e: self.disp(f"can't send message {msg!r}: {e}", error=True)