Mercurial > libervia-backend
changeset 2794:33fa70c102de
plugin XEP-0045: fixed crash when <delay> is used at an unexpected time.
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 26 Jan 2019 20:07:45 +0100 |
parents | 181735d1b062 |
children | 25639611c303 |
files | sat/core/xmpp.py sat/plugins/plugin_xep_0045.py |
diffstat | 2 files changed, 22 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/sat/core/xmpp.py Fri Jan 25 09:06:29 2019 +0100 +++ b/sat/core/xmpp.py Sat Jan 26 20:07:45 2019 +0100 @@ -871,7 +871,10 @@ if message_elt.uri is None: # wokkel element parsing strip out root namespace - message_elt.uri = C.NS_CLIENT + message_elt.defaultUri = message_elt.uri = C.NS_CLIENT + for c in message_elt.children: + if c.uri is None: + c.uri == C.NS_CLIENT elif message_elt.uri != C.NS_CLIENT: log.warning(_( u"received <message> with a wrong namespace: {xml}"
--- a/sat/plugins/plugin_xep_0045.py Fri Jan 25 09:06:29 2019 +0100 +++ b/sat/plugins/plugin_xep_0045.py Sat Jan 26 20:07:45 2019 +0100 @@ -1133,6 +1133,24 @@ u"received history in unexpected state in room {room} (state: " u"{state})").format(room = room.roomJID.userhost(), state = room.state)) + if not hasattr(room, "_history_d"): + # XXX: this hack is due to buggy behaviour seen in the wild because of the + # "mod_delay" prosody module being activated. This module add an + # unexpected <delay> elements which break our workflow. + log.warning(_(u"storing the unexpected message anyway, to avoid loss")) + # we have to restore URI which are stripped by wokkel parsing + for c in message.element.children: + if c.uri is None: + c.uri = C.NS_CLIENT + mess_data = self.client.messageProt.parseMessage(message.element) + message.element._mess_data = mess_data + self._addToHistory(None, user, message) + if mess_data[u'message'] or mess_data[u'subject']: + self.host.bridge.messageNew( + *self.client.messageGetBridgeArgs(mess_data), + profile=self.client.profile + ) + return room._history_d.addCallback(self._addToHistory, user, message) room._history_d.addErrback(self._addToHistoryEb)