core,bridge: sendMessage bridge method is now async

This commit is contained in:
Goffi 2013-12-17 01:46:45 +01:00
commit bc776be0f2

View file

@ -509,7 +509,7 @@ class SAT(service.Service):
def _sendMessage(self, to_s, msg, subject=None, mess_type='auto', extra={}, profile_key='@NONE@'):
to_jid = jid.JID(to_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
self.sendMessage(to_jid, msg, subject, mess_type, {unicode(key): unicode(value) for key, value in extra.items()}, profile_key=profile_key)
return self.sendMessage(to_jid, msg, subject, mess_type, {unicode(key): unicode(value) for key, value in extra.items()}, profile_key=profile_key)
def sendMessage(self, to_jid, msg, subject=None, mess_type='auto', extra={}, no_trigger=False, profile_key='@NONE@'):
#FIXME: check validity of recipient
@ -550,7 +550,7 @@ class SAT(service.Service):
if not no_trigger:
if not self.trigger.point("sendMessage", mess_data, treatments, profile):
return
return defer.succeed(None)
debug(_("Sending jabber message of type [%(type)s] to %(to)s...") % {"type": mess_data["type"], "to": to_jid.full()})
mess_data['xml'] = domish.Element((None, 'message'))
@ -569,12 +569,14 @@ class SAT(service.Service):
debug(text)
elif e.check(AbortSendMessage):
warning(text)
return e
else:
error("Unmanaged exception: %s" % text)
return e
treatments.addCallbacks(self.sendAndStoreMessage, sendErrback, [False, profile])
treatments.callback(mess_data)
return treatments
def sendAndStoreMessage(self, mess_data, skip_send=False, profile=None):
"""Actually send and store the message to history, after all the treatments