Diff

mod_groups_internal/mod_groups_internal.lua @ 6208:e20901443eae draft

Merge
author Trần H. Trung <xmpp:trần.h.trung@trung.fun>
date Mon, 17 Mar 2025 23:42:11 +0700
parent 5848:865c77b5c6dc
child 6211:750d64c47ec6
line wrap: on
line diff
--- a/mod_groups_internal/mod_groups_internal.lua	Wed Feb 26 19:36:35 2025 +0700
+++ b/mod_groups_internal/mod_groups_internal.lua	Mon Mar 17 23:42:11 2025 +0700
@@ -11,7 +11,7 @@
 local group_members_store = module:open_store("groups");
 local group_memberships = module:open_store("groups", "map");
 
-local muc_host_name = module:get_option("groups_muc_host", "groups."..host);
+local muc_host_name = module:get_option("groups_muc_host");
 local muc_host = nil;
 
 local is_contact_subscribed = rostermanager.is_contact_subscribed;
@@ -31,6 +31,7 @@
 	if group_name then
 		local user_roster = rostermanager.load_roster(user, host);
 		user_roster[contact_jid].groups[group_name] = true;
+		rostermanager.save_roster(user, host, user_roster, contact_jid);
 	end
 
 	-- Push updates to both rosters
@@ -207,10 +208,18 @@
 function delete(group_id)
 	if group_members_store:set(group_id, nil) then
 		local group_info = get_info(group_id);
-		if group_info and group_info.muc_jid then
-			local room = muc_host.get_room_from_jid(group_info.muc_jid)
-			if room then
-				room:destroy()
+		if group_info then
+			if group_info.muc_jid then
+				local room = muc_host.get_room_from_jid(group_info.muc_jid)
+				if room then
+					room:destroy()
+				end
+			end
+			for _, muc_jid in ipairs(group_info.mucs) do
+				local room = muc_host.get_room_from_jid(muc_jid)
+				if room then
+					room:destroy()
+				end
 			end
 		end
 		return group_info_store:set(group_id, nil);