From 07f56779a843bbfd0e1305e6cf99b0251d48b62e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20=E2=80=9Cpep=E2=80=9D=20Buquet?= Date: Fri, 24 Dec 2021 23:10:03 +0100 Subject: [PATCH] impromptu: Wait for the self-presence to configure and invite MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit MucTab.join doesn't allow us to wait until we are fully joined to a MUC, causing races between the MUC creation and configuration, making it impossible for invited users to join the MUC. This adds a disposable event (discarded after first use) that listens on the self-presence on the generated JID. Signed-off-by: Maxime “pep” Buquet --- poezio/core/core.py | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/poezio/core/core.py b/poezio/core/core.py index ec64f0a0..e327d4f1 100644 --- a/poezio/core/core.py +++ b/poezio/core/core.py @@ -1017,18 +1017,27 @@ class Core: return None self.open_new_room(room, nick).join() - iq = self._impromptu_room_form(room) - try: - await iq.send() - except (IqError, IqTimeout): - self.information('Failed to configure impromptu room.', 'Info') - # TODO: destroy? leave room. - return None - self.information('Room %s created' % room, 'Info') + async def join_callback(_presence): + iq = self._impromptu_room_form(room) + try: + await iq.send() + except (IqError, IqTimeout): + self.information('Failed to configure impromptu room.', 'Info') + # TODO: destroy? leave room. + return None - for jid in jids: - await self.invite(jid, room, force_mediated=True) + self.information('Room %s created' % room, 'Info') + + for jid in jids: + await self.invite(jid, room, force_mediated=True) + + # TODO: Use xep_0045's async join_muc_wait somehow instead? + self.xmpp.add_event_handler( + 'muc::%s::self-presence' % room.bare, + join_callback, + disposable=True, + ) ####################### Tab logic-related things ##############################