changeset 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 157fa4e535b0
children 8b69e0b56db2
files mod_groups_internal/mod_groups_internal.lua
diffstat 1 files changed, 21 insertions(+), 0 deletions(-) [+]
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();