From a873edb9eca38829186c097d3ba19271d383efb4 Mon Sep 17 00:00:00 2001 From: Ikjot Singh Dhody Date: Wed, 21 Jun 2023 12:20:14 +0530 Subject: [PATCH] feat(xep): Check for null nick before leaveRoom. Signed-off-by: Ikjot Singh Dhody --- packages/moxxmpp/lib/src/xeps/xep_0045/errors.dart | 5 +++++ packages/moxxmpp/lib/src/xeps/xep_0045/xep_0045.dart | 3 +++ 2 files changed, 8 insertions(+) diff --git a/packages/moxxmpp/lib/src/xeps/xep_0045/errors.dart b/packages/moxxmpp/lib/src/xeps/xep_0045/errors.dart index f1771ac..7cc2b8f 100644 --- a/packages/moxxmpp/lib/src/xeps/xep_0045/errors.dart +++ b/packages/moxxmpp/lib/src/xeps/xep_0045/errors.dart @@ -12,3 +12,8 @@ class InvalidDiscoInfoResponse extends MUCError {} /// Returned when no nickname was specified from the client side while trying to /// perform some actions on the MUC, such as joining the room. class NoNicknameSpecified extends MUCError {} + +/// This error occurs when a user attempts to perform an action that requires +/// them to be a member of a room, but they are not currently joined to +/// that room. +class RoomNotJoinedError extends MUCError {} diff --git a/packages/moxxmpp/lib/src/xeps/xep_0045/xep_0045.dart b/packages/moxxmpp/lib/src/xeps/xep_0045/xep_0045.dart index b6a7859..80c50a4 100644 --- a/packages/moxxmpp/lib/src/xeps/xep_0045/xep_0045.dart +++ b/packages/moxxmpp/lib/src/xeps/xep_0045/xep_0045.dart @@ -97,6 +97,9 @@ class MUCManager extends XmppManagerBase { _mucRoomCache.remove(roomJid); return nick; }); + if (nick == null) { + return Result(RoomNotJoinedError); + } await getAttributes().sendStanza( StanzaDetails( Stanza.presence(