Comparison

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
comparison
equal deleted inserted replaced
5945:805515dd2960 6208:e20901443eae
9 9
10 local group_info_store = module:open_store("group_info", "keyval+"); 10 local group_info_store = module:open_store("group_info", "keyval+");
11 local group_members_store = module:open_store("groups"); 11 local group_members_store = module:open_store("groups");
12 local group_memberships = module:open_store("groups", "map"); 12 local group_memberships = module:open_store("groups", "map");
13 13
14 local muc_host_name = module:get_option("groups_muc_host", "groups."..host); 14 local muc_host_name = module:get_option("groups_muc_host");
15 local muc_host = nil; 15 local muc_host = nil;
16 16
17 local is_contact_subscribed = rostermanager.is_contact_subscribed; 17 local is_contact_subscribed = rostermanager.is_contact_subscribed;
18 18
19 -- Make a *one-way* subscription. User will see when contact is online, 19 -- Make a *one-way* subscription. User will see when contact is online,
29 rostermanager.process_inbound_subscription_approval(user, host, contact_jid); 29 rostermanager.process_inbound_subscription_approval(user, host, contact_jid);
30 30
31 if group_name then 31 if group_name then
32 local user_roster = rostermanager.load_roster(user, host); 32 local user_roster = rostermanager.load_roster(user, host);
33 user_roster[contact_jid].groups[group_name] = true; 33 user_roster[contact_jid].groups[group_name] = true;
34 rostermanager.save_roster(user, host, user_roster, contact_jid);
34 end 35 end
35 36
36 -- Push updates to both rosters 37 -- Push updates to both rosters
37 rostermanager.roster_push(user, host, contact_jid); 38 rostermanager.roster_push(user, host, contact_jid);
38 rostermanager.roster_push(contact, host, user_jid); 39 rostermanager.roster_push(contact, host, user_jid);
205 end 206 end
206 207
207 function delete(group_id) 208 function delete(group_id)
208 if group_members_store:set(group_id, nil) then 209 if group_members_store:set(group_id, nil) then
209 local group_info = get_info(group_id); 210 local group_info = get_info(group_id);
210 if group_info and group_info.muc_jid then 211 if group_info then
211 local room = muc_host.get_room_from_jid(group_info.muc_jid) 212 if group_info.muc_jid then
212 if room then 213 local room = muc_host.get_room_from_jid(group_info.muc_jid)
213 room:destroy() 214 if room then
215 room:destroy()
216 end
217 end
218 for _, muc_jid in ipairs(group_info.mucs) do
219 local room = muc_host.get_room_from_jid(muc_jid)
220 if room then
221 room:destroy()
222 end
214 end 223 end
215 end 224 end
216 return group_info_store:set(group_id, nil); 225 return group_info_store:set(group_id, nil);
217 end 226 end
218 return nil, "internal-server-error"; 227 return nil, "internal-server-error";