comparison sat/plugins/plugin_xep_0045.py @ 3086:13be04a70e2f

plugin XEP-0045: show join error even if it's not a StanzaError, log it with warning instead of error
author Goffi <goffi@goffi.org>
date Fri, 20 Dec 2019 12:28:04 +0100
parents 16925f494820
children ab7e8ade848a
comparison
equal deleted inserted replaced
3085:c048fc192739 3086:13be04a70e2f
278 d = client._muc_client.configure(room.roomJID, {}) 278 d = client._muc_client.configure(room.roomJID, {})
279 d.addErrback(self.host.logErrback, 279 d.addErrback(self.host.logErrback,
280 msg=_('Error while configuring the room: {failure_}')) 280 msg=_('Error while configuring the room: {failure_}'))
281 return room.fully_joined 281 return room.fully_joined
282 282
283 def _joinEb(self, failure, client, room_jid, nick, password): 283 def _joinEb(self, failure_, client, room_jid, nick, password):
284 """Called when something is going wrong when joining the room""" 284 """Called when something is going wrong when joining the room"""
285 try: 285 try:
286 condition = failure.value.condition 286 condition = failure_.value.condition
287 except AttributeError: 287 except AttributeError:
288 msg_suffix = '' 288 msg_suffix = f': {failure_}'
289 else: 289 else:
290 if condition == 'conflict': 290 if condition == 'conflict':
291 # we have a nickname conflict, we try again with "_" suffixed to current nickname 291 # we have a nickname conflict, we try again with "_" suffixed to current nickname
292 nick += '_' 292 nick += '_'
293 return client._muc_client.join(room_jid, nick, password).addCallbacks(self._joinCb, self._joinEb, (client, room_jid, nick), errbackArgs=(client, room_jid, nick, password)) 293 return client._muc_client.join(room_jid, nick, password).addCallbacks(self._joinCb, self._joinEb, (client, room_jid, nick), errbackArgs=(client, room_jid, nick, password))
298 password_ui.addPassword('password') 298 password_ui.addPassword('password')
299 d = xml_tools.deferXMLUI(self.host, password_ui, profile=client.profile) 299 d = xml_tools.deferXMLUI(self.host, password_ui, profile=client.profile)
300 d.addCallback(self._passwordUICb, client, room_jid, nick) 300 d.addCallback(self._passwordUICb, client, room_jid, nick)
301 return d 301 return d
302 302
303 msg_suffix = ' with condition "{}"'.format(failure.value.condition) 303 msg_suffix = ' with condition "{}"'.format(failure_.value.condition)
304 304
305 mess = D_("Error while joining the room {room}{suffix}".format( 305 mess = D_("Error while joining the room {room}{suffix}".format(
306 room = room_jid.userhost(), suffix = msg_suffix)) 306 room = room_jid.userhost(), suffix = msg_suffix))
307 log.error(mess) 307 log.warning(mess)
308 xmlui = xml_tools.note(mess, D_("Group chat error"), level=C.XMLUI_DATA_LVL_ERROR) 308 xmlui = xml_tools.note(mess, D_("Group chat error"), level=C.XMLUI_DATA_LVL_ERROR)
309 self.host.actionNew({'xmlui': xmlui.toXml()}, profile=client.profile) 309 self.host.actionNew({'xmlui': xmlui.toXml()}, profile=client.profile)
310 310
311 @staticmethod 311 @staticmethod
312 def _getOccupants(room): 312 def _getOccupants(room):