summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxime “pep” Buquet <pep@bouah.net>2021-12-24 23:10:03 +0100
committerMaxime “pep” Buquet <pep@bouah.net>2021-12-24 23:10:03 +0100
commit07f56779a843bbfd0e1305e6cf99b0251d48b62e (patch)
treece0a5a1d6ab7a5b5dcc3196b727983e78d9c8ad0
parent49734de674eec666a9ff6a955ad2c01843f67908 (diff)
downloadpoezio-07f56779a843bbfd0e1305e6cf99b0251d48b62e.tar.gz
poezio-07f56779a843bbfd0e1305e6cf99b0251d48b62e.tar.bz2
poezio-07f56779a843bbfd0e1305e6cf99b0251d48b62e.tar.xz
poezio-07f56779a843bbfd0e1305e6cf99b0251d48b62e.zip
impromptu: Wait for the self-presence to configure and invite
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 <pep@bouah.net>
-rw-r--r--poezio/core/core.py29
1 files 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 ##############################