mod_muc_rai: Ignore attempts to re-subscribe from the same full JID
authorMatthew Wild <mwild1@gmail.com>
Tue, 28 Apr 2020 16:54:21 +0100
changeset 4002 67047ed63b15
parent 4001 0e72dd70afff
child 4003 22784f001b7f
mod_muc_rai: Ignore attempts to re-subscribe from the same full JID
mod_muc_rai/mod_muc_rai.lua
--- a/mod_muc_rai/mod_muc_rai.lua	Tue Apr 28 10:03:17 2020 +0100
+++ b/mod_muc_rai/mod_muc_rai.lua	Tue Apr 28 16:54:21 2020 +0100
@@ -137,9 +137,17 @@
 	return muc_affiliation_store:get_all(jid.bare(user_jid));
 end
 
+local function is_subscribed(user_jid)
+	return not not subscribed_users:get(user_jid);
+end
+
 -- Subscribes to all rooms that the user has an interest in
 -- Returns a set of room JIDs that have already had activity (thus no subscription)
 local function subscribe_all_rooms(user_jid)
+	if is_subscribed(user_jid) then
+		return nil;
+	end
+
 	-- Send activity notifications for all relevant rooms
 	local interested_rooms, err = get_interested_rooms(user_jid);