changeset 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 b3e0295e14a3
files mod_groups_internal/mod_groups_internal.lua
diffstat 1 files changed, 18 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mod_groups_internal/mod_groups_internal.lua	Tue Feb 02 22:28:09 2021 +0100
+++ b/mod_groups_internal/mod_groups_internal.lua	Wed Feb 03 18:02:39 2021 +0100
@@ -216,6 +216,15 @@
 			module:log("warn", "failed to update affiliation for %s in %s", username, group_info.muc_jid);
 		end
 	end
+	module:fire_event(
+		"group-user-added",
+		{
+			id = group_id,
+			user = username,
+			host = host,
+			group_info = group_info,
+		}
+	)
 	if not delay_update then
 		do_all_group_subscriptions_by_group(group_id);
 	end
@@ -239,6 +248,15 @@
 			module:log("warn", "failed to update affiliation for %s in %s", username, group_info.muc_jid);
 		end
 	end
+	module:fire_event(
+		"group-user-removed",
+		{
+			id = group_id,
+			user = username,
+			host = host,
+			group_info = group_info,
+		}
+	)
 	return true;
 end