bridge: messageSend's extra is now serialised
This commit is contained in:
parent
74a60a2e5b
commit
a194874638
7 changed files with 16 additions and 15 deletions
|
|
@ -428,7 +428,7 @@ doc_return=Dict where contact JID is the key, and value is the subscription type
|
|||
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_1=message: body of the message:
|
|||
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]
|
||||
|
|
|
|||
|
|
@ -457,10 +457,10 @@ class DbusObject(dbus.service.Object):
|
|||
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}',
|
||||
|
|
|
|||
|
|
@ -783,18 +783,17 @@ class SAT(service.Service):
|
|||
|
||||
## 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):
|
||||
|
|
|
|||
|
|
@ -555,8 +555,9 @@ class SatXMPPEntity:
|
|||
"""
|
||||
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
|
||||
|
|
|
|||
|
|
@ -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.i18n import _
|
|||
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 dateutil
|
|||
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")
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@ class Send(base.CommandBase):
|
|||
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)
|
||||
|
|
|
|||
|
|
@ -855,7 +855,7 @@ class QuickApp(object):
|
|||
message,
|
||||
subject,
|
||||
mess_type,
|
||||
extra,
|
||||
data_format.serialise(extra),
|
||||
profile_key,
|
||||
callback=callback,
|
||||
errback=errback,
|
||||
|
|
|
|||
Loading…
Reference in a new issue