Diff

mod_groups_internal/mod_groups_internal.lua @ 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
parent 4706:428861d1d1e4
child 5708:9edc698848e9
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