Mercurial > libervia-backend
diff sat/plugins/plugin_xep_0045.py @ 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 | 003b8b4b56a7 |
children | 27d9d25ec3cd |
line wrap: on
line diff
--- 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)