comparison libervia/backend/plugins/plugin_xep_0045.py @ 4083:2ea567afc0cf

plugin XEP-0045: fix calls to `join`
author Goffi <goffi@goffi.org>
date Wed, 07 Jun 2023 22:26:17 +0200
parents 4b842c1fb686
children d861ad696797
comparison
equal deleted inserted replaced
4082:72e91ea3bc16 4083:2ea567afc0cf
267 ] 267 ]
268 268
269 def _ui_room_join_cb(self, data, profile): 269 def _ui_room_join_cb(self, data, profile):
270 room_jid = jid.JID(data['index']) 270 room_jid = jid.JID(data['index'])
271 client = self.host.get_client(profile) 271 client = self.host.get_client(profile)
272 self.join(client, room_jid) 272 defer.ensureDeferred(
273 self.join(client, room_jid)
274 )
273 return {} 275 return {}
274 276
275 def _password_ui_cb(self, data, client, room_jid, nick): 277 def _password_ui_cb(self, data, client, room_jid, nick):
276 """Called when the user has given room password (or cancelled)""" 278 """Called when the user has given room password (or cancelled)"""
277 if C.bool(data.get(C.XMLUI_DATA_CANCELLED, "false")): 279 if C.bool(data.get(C.XMLUI_DATA_CANCELLED, "false")):
537 room_id=room_jid_s, 539 room_id=room_jid_s,
538 muc_service=str(muc_service)))) 540 muc_service=str(muc_service))))
539 if not room_jid.user: 541 if not room_jid.user:
540 room_jid.user, room_jid.host = room_jid.host, muc_service 542 room_jid.user, room_jid.host = room_jid.host, muc_service
541 else: 543 else:
542 room_jid = self.get_unique_name(profile_key=client.profile) 544 room_jid = self.get_unique_name(client)
543 # TODO: error management + signal in bridge 545 # TODO: error management + signal in bridge
544 d = self.join(client, room_jid, nick, options or None) 546 d = defer.ensureDeferred(
547 self.join(client, room_jid, nick, options or None)
548 )
549
545 d.addCallback(lambda room: [False] + self._get_room_joined_args(room, client.profile)) 550 d.addCallback(lambda room: [False] + self._get_room_joined_args(room, client.profile))
546 d.addErrback(self._join_eb, client) 551 d.addErrback(self._join_eb, client)
547 return d 552 return d
548 553
549 async def join( 554 async def join(
695 # the command has been entered in a one2one conversation, so we use 700 # the command has been entered in a one2one conversation, so we use
696 # our server MUC service as default service 701 # our server MUC service as default service
697 muc_service = client.muc_service or "" 702 muc_service = client.muc_service or ""
698 nick = client.jid.user 703 nick = client.jid.user
699 room_jid = self.text_cmds.get_room_jid(room_raw, muc_service) 704 room_jid = self.text_cmds.get_room_jid(room_raw, muc_service)
700 self.join(client, room_jid, nick, {}) 705 defer.ensureDeferred(
706 self.join(client, room_jid, nick, {})
707 )
701 708
702 return False 709 return False
703 710
704 def cmd_leave(self, client, mess_data): 711 def cmd_leave(self, client, mess_data):
705 """quit a room 712 """quit a room