# HG changeset patch
# User Matthew Wild <mwild1@gmail.com>
# Date 1701950881 0
# Node ID e5ddae99faa8f27206090529c7f5cf3611992919
# Parent  33e5edbd6a4a5a0025a17f839f7c49efce8c2f1c
mod_user_account_management: Clear pending deletion if account re-enabled

diff -r 33e5edbd6a4a -r e5ddae99faa8 plugins/mod_user_account_management.lua
--- a/plugins/mod_user_account_management.lua	Tue Dec 05 11:39:11 2023 +0000
+++ b/plugins/mod_user_account_management.lua	Thu Dec 07 12:08:01 2023 +0000
@@ -171,6 +171,12 @@
 	return true, "Account restored";
 end
 
+-- Automatically clear pending deletion if an account is re-enabled
+module:context("*"):hook("user-enabled", function (event)
+	if event.host ~= module.host then return; end
+	deleted_accounts:set(event.username, nil);
+end);
+
 local cleanup_time = module:measure("cleanup", "times");
 
 function cleanup_soft_deleted_accounts()