Mercurial > libervia-backend
comparison src/plugins/plugin_xep_0033.py @ 1205:3e234902177a
plugin XEP-0033: fixes sending the message after the changes made in rev 1052 (e88bff4c8b77)
author | souliane <souliane@mailoo.org> |
---|---|
date | Thu, 11 Sep 2014 15:38:57 +0200 |
parents | e88bff4c8b77 |
children | 0befb14ecf62 |
comparison
equal
deleted
inserted
replaced
1204:2ee0cd57144e | 1205:3e234902177a |
---|---|
117 Ideas: | 117 Ideas: |
118 - fix Prosody plugin to check if target server support the feature | 118 - fix Prosody plugin to check if target server support the feature |
119 - redesign the database to save only one entry to the database | 119 - redesign the database to save only one entry to the database |
120 - change the newMessage signal to eventually pass more than one recipient | 120 - change the newMessage signal to eventually pass more than one recipient |
121 """ | 121 """ |
122 def send(mess_data, skip_send=False): | |
123 client = self.host.profiles[profile] | |
124 d = defer.Deferred() | |
125 if not skip_send: | |
126 d.addCallback(self.host._sendMessageToStream, client) | |
127 d.addCallback(self.host._storeMessage, client) | |
128 d.addCallback(self.host.sendMessageToBridge, client) | |
129 d.addErrback(lambda failure: failure.trap(exceptions.CancelError)) | |
130 return d.callback(mess_data) | |
131 | |
122 def discoCallback(entities, to_jid_s): | 132 def discoCallback(entities, to_jid_s): |
123 history_data = copy.deepcopy(mess_data) | 133 history_data = copy.deepcopy(mess_data) |
124 history_data['to'] = JID(to_jid_s) | 134 history_data['to'] = JID(to_jid_s) |
125 history_data['xml']['to'] = to_jid_s | 135 history_data['xml']['to'] = to_jid_s |
126 if entities: | 136 if entities: |
127 if entities not in self.internal_data[timestamp]: | 137 if entities not in self.internal_data[timestamp]: |
128 sent_data = copy.deepcopy(mess_data) | 138 sent_data = copy.deepcopy(mess_data) |
129 sent_data['to'] = JID(JID(to_jid_s).host) | 139 sent_data['to'] = JID(JID(to_jid_s).host) |
130 sent_data['xml']['to'] = JID(to_jid_s).host | 140 sent_data['xml']['to'] = JID(to_jid_s).host |
131 self.host.sendAndStoreMessage(sent_data, False, profile) | 141 send(sent_data) |
132 self.internal_data[timestamp].append(entities) | 142 self.internal_data[timestamp].append(entities) |
133 # we still need to fill the history and signal the echo... | 143 # we still need to fill the history and signal the echo... |
134 self.host.sendAndStoreMessage(history_data, True, profile) | 144 send(history_data, skip_send=True) |
135 else: | 145 else: |
136 # target server misses the addressing feature | 146 # target server misses the addressing feature |
137 self.host.sendAndStoreMessage(history_data, False, profile) | 147 send(history_data) |
138 | 148 |
139 def errback(failure, to_jid): | 149 def errback(failure, to_jid): |
140 discoCallback(None, to_jid) | 150 discoCallback(None, to_jid) |
141 | 151 |
142 timestamp = time() | 152 timestamp = time() |