comparison mod_groups_internal/mod_groups_internal.lua @ 4424:679be18e6a5e

mod_groups_internal: emit events for group membership changes
author Jonas Schäfer <jonas@wielicki.name>
date Wed, 03 Feb 2021 18:02:39 +0100
parents ca821df93cb9
children 71c495fa03f3
comparison
equal deleted inserted replaced
4423:ca821df93cb9 4424:679be18e6a5e
214 module:log("debug", "set user %s to be member in %s and sent invite", username, group_info.muc_jid); 214 module:log("debug", "set user %s to be member in %s and sent invite", username, group_info.muc_jid);
215 else 215 else
216 module:log("warn", "failed to update affiliation for %s in %s", username, group_info.muc_jid); 216 module:log("warn", "failed to update affiliation for %s in %s", username, group_info.muc_jid);
217 end 217 end
218 end 218 end
219 module:fire_event(
220 "group-user-added",
221 {
222 id = group_id,
223 user = username,
224 host = host,
225 group_info = group_info,
226 }
227 )
219 if not delay_update then 228 if not delay_update then
220 do_all_group_subscriptions_by_group(group_id); 229 do_all_group_subscriptions_by_group(group_id);
221 end 230 end
222 return true; 231 return true;
223 end 232 end
237 room:set_affiliation(true, user_jid, nil); 246 room:set_affiliation(true, user_jid, nil);
238 else 247 else
239 module:log("warn", "failed to update affiliation for %s in %s", username, group_info.muc_jid); 248 module:log("warn", "failed to update affiliation for %s in %s", username, group_info.muc_jid);
240 end 249 end
241 end 250 end
251 module:fire_event(
252 "group-user-removed",
253 {
254 id = group_id,
255 user = username,
256 host = host,
257 group_info = group_info,
258 }
259 )
242 return true; 260 return true;
243 end 261 end
244 262
245 function sync(group_id) 263 function sync(group_id)
246 do_all_group_subscriptions_by_group(group_id); 264 do_all_group_subscriptions_by_group(group_id);