changeset 4707:27f7ed9f50cd

mod_groups_internal: Remove deleted user from groups
author Kim Alvefur <zash@zash.se>
date Tue, 12 Oct 2021 13:57:24 +0200
parents 428861d1d1e4
children 25fd5e268f90
files mod_groups_internal/mod_groups_internal.lua
diffstat 1 files changed, 8 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mod_groups_internal/mod_groups_internal.lua	Tue Oct 12 13:52:12 2021 +0200
+++ b/mod_groups_internal/mod_groups_internal.lua	Tue Oct 12 13:57:24 2021 +0200
@@ -305,6 +305,14 @@
 	end
 end
 
+module:hook_global("user-deleted", function(event)
+	if event.host ~= module.host then return end
+	local username = event.username;
+	for group_id in user_groups(username) do
+		remove_member(group_id, username);
+	end
+end);
+
 if prosody.start_time then  -- server already started
 	setup();
 else