From 600217bb44340ed891c39de6b5232809b7eb203d Mon Sep 17 00:00:00 2001 From: bgrozev Date: Tue, 14 Nov 2023 14:15:17 -0600 Subject: [PATCH] fix: Always send presence unavailable when leaving a MUC. (#1122) --- .../main/kotlin/org/jitsi/jicofo/xmpp/muc/ChatRoomImpl.kt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/jicofo-common/src/main/kotlin/org/jitsi/jicofo/xmpp/muc/ChatRoomImpl.kt b/jicofo-common/src/main/kotlin/org/jitsi/jicofo/xmpp/muc/ChatRoomImpl.kt index dfe189a7f3..71668a6356 100644 --- a/jicofo-common/src/main/kotlin/org/jitsi/jicofo/xmpp/muc/ChatRoomImpl.kt +++ b/jicofo-common/src/main/kotlin/org/jitsi/jicofo/xmpp/muc/ChatRoomImpl.kt @@ -280,6 +280,14 @@ class ChatRoomImpl( // listeners lingering around if (isJoined) { muc.leave() + } else { + // If the join attempt timed out the XMPP server might have processed it and created the MUC, and + // since the XMPP connection is long-lived the MUC will leak. + val leavePresence = connection.stanzaFactory.buildPresenceStanza() + .ofType(Presence.Type.unavailable) + .to(myOccupantJid) + .build() + connection.sendStanza(leavePresence) } } catch (e: Exception) { // when the connection is not connected or we get NotConnectedException, this is expected (skip log)