Mercurial > prosody-modules
diff mod_groups_internal/mod_groups_internal.lua @ 4430:71c495fa03f3
mod_groups_internal: allow force-emitting group member addition events
This is useful when a new plugin was loaded which handles that
event to add some value.
Then the command can be called (**not** from the plugin but from
an upcoming admin shell module) to synchronise things.
author | Jonas Schäfer <jonas@wielicki.name> |
---|---|
date | Fri, 05 Feb 2021 15:45:28 +0100 |
parents | 679be18e6a5e |
children | 428861d1d1e4 |
line wrap: on
line diff
--- a/mod_groups_internal/mod_groups_internal.lua Fri Feb 05 12:36:48 2021 +0000 +++ b/mod_groups_internal/mod_groups_internal.lua Fri Feb 05 15:45:28 2021 +0100 @@ -264,6 +264,27 @@ do_all_group_subscriptions_by_group(group_id); end +function emit_member_events(group_id) + local group_info, err = get_info(group_id) + if group_info == nil then + return false, err + end + + for username in pairs(get_members(group_id)) do + module:fire_event( + "group-user-added", + { + id = group_id, + user = username, + host = host, + group_info = group_info, + } + ) + end + + return true +end + -- Returns iterator over group ids function groups() return group_info_store:users();