Mercurial > libervia-backend
changeset 749:192b804ee446
plugin XEP-0033: bug fix for sending messages with the addressing feature to several servers
author | souliane <souliane@mailoo.org> |
---|---|
date | Mon, 16 Dec 2013 14:48:28 +0100 |
parents | a0f4a80a6536 |
children | c8b9f675ac17 |
files | src/plugins/plugin_xep_0033.py |
diffstat | 1 files changed, 11 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/plugins/plugin_xep_0033.py Mon Dec 16 14:36:38 2013 +0100 +++ b/src/plugins/plugin_xep_0033.py Mon Dec 16 14:48:28 2013 +0100 @@ -29,10 +29,11 @@ from wokkel.subprotocols import XMPPHandler from threading import Timer from twisted.words.xish import domish -from twisted.internet import defer +from twisted.internet import defer, threads from sat.core.sat_main import MessageSentAndStored, AbortSendMessage from sat.tools.misc import TriggerManager +from time import time # TODO: fix Prosody "addressing" plugin to leave the concerned bcc according to the spec: # @@ -69,6 +70,7 @@ def __init__(self, host): logging.info(_("Extended Stanza Addressing plugin initialization")) self.host = host + self.internal_data = {} host.trigger.add("sendMessage", self.sendMessageTrigger, TriggerManager.MIN_PRIORITY) host.trigger.add("MessageReceived", self.messageReceivedTrigger) @@ -119,10 +121,9 @@ new_data['to'] = JID(to_jid) new_data['xml']['to'] = to_jid if entity: - if 'address' in mess_data['extra']: + if entity not in self.internal_data[timestamp]: self.host.sendAndStoreMessage(mess_data, False, profile) - # just to remember that the message has been sent - del mess_data['extra']['address'] + self.internal_data[timestamp].append(entity) # we still need to fill the history and signal the echo... self.host.sendAndStoreMessage(new_data, True, profile) else: @@ -132,11 +133,17 @@ def errback(failure, to_jid): discoCallback(None, to_jid) + timestamp = time() + self.internal_data[timestamp] = [] + defer_list = [] for type_, jid_ in entries: d = defer.Deferred() d.addCallback(self.host.requestServerDisco, JID(JID(jid_).host), profile_key=profile) d.addCallbacks(discoCallback, errback, callbackArgs=[jid_], errbackArgs=[jid_]) d.callback(NS_ADDRESS) + defer_list.append(d) + d = defer.Deferred().addCallback(lambda dummy: self.internal_data.pop(timestamp)) + defer.DeferredList(defer_list).chainDeferred(d) raise MessageSentAndStored("XEP-0033 took over")