comparison 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
comparison
equal deleted inserted replaced
2793:181735d1b062 2794:33fa70c102de
1131 if room.state != ROOM_STATE_SELF_PRESENCE: 1131 if room.state != ROOM_STATE_SELF_PRESENCE:
1132 log.warning(_( 1132 log.warning(_(
1133 u"received history in unexpected state in room {room} (state: " 1133 u"received history in unexpected state in room {room} (state: "
1134 u"{state})").format(room = room.roomJID.userhost(), 1134 u"{state})").format(room = room.roomJID.userhost(),
1135 state = room.state)) 1135 state = room.state))
1136 if not hasattr(room, "_history_d"):
1137 # XXX: this hack is due to buggy behaviour seen in the wild because of the
1138 # "mod_delay" prosody module being activated. This module add an
1139 # unexpected <delay> elements which break our workflow.
1140 log.warning(_(u"storing the unexpected message anyway, to avoid loss"))
1141 # we have to restore URI which are stripped by wokkel parsing
1142 for c in message.element.children:
1143 if c.uri is None:
1144 c.uri = C.NS_CLIENT
1145 mess_data = self.client.messageProt.parseMessage(message.element)
1146 message.element._mess_data = mess_data
1147 self._addToHistory(None, user, message)
1148 if mess_data[u'message'] or mess_data[u'subject']:
1149 self.host.bridge.messageNew(
1150 *self.client.messageGetBridgeArgs(mess_data),
1151 profile=self.client.profile
1152 )
1153 return
1136 room._history_d.addCallback(self._addToHistory, user, message) 1154 room._history_d.addCallback(self._addToHistory, user, message)
1137 room._history_d.addErrback(self._addToHistoryEb) 1155 room._history_d.addErrback(self._addToHistoryEb)
1138 1156
1139 ## subject ## 1157 ## subject ##
1140 1158