# HG changeset patch # User Matthew Wild # Date 1780673095 -3600 # Node ID 55a7143a58ecc8e973e5c8ee30f2077dcc4a5da9 # Parent a8ce6f45ba35047512b06219200aa122e27849f1 mod_tombstones: Add shell commands for listing and clearing tombstones diff -r a8ce6f45ba35 -r 55a7143a58ec plugins/mod_tombstones.lua --- a/plugins/mod_tombstones.lua Fri Jun 05 16:24:39 2026 +0100 +++ b/plugins/mod_tombstones.lua Fri Jun 05 16:24:55 2026 +0100 @@ -125,3 +125,50 @@ return true; end end, 1); + +--- shell commands +module:add_item("shell-command", { + section = "user"; + name = "list_deleted"; + desc = "List deleted user accounts (tombstones)"; + args = { + { name = "host", type = "string" }; + }; + host_selector = "host"; + handler = function (self, host) --luacheck: ignore 212/host + local c = 0; + for username in pairs(graveyard:get(nil)) do + c = c + 1; + self.session.print(username); + end + return true, ("Showing %d deleted accounts"):format(c); + end; +}); + +module:add_item("shell-command", { + section = "user"; + name = "forget"; + desc = "Forget a deleted user account (tombstone)"; + args = { + { name = "jid", type = "string" }; + }; + host_selector = "jid"; + handler = function (self, user_jid) --luacheck: ignore 212/self + local username = jid_node(user_jid); + if not has_tombstone(username) then + if require "core.usermanager".user_exists(username, module.host) then + return nil, "User account has not been deleted"; + else + return nil, "User account does not exist"; + end + end + + local ok, err = clear_tombstone(username); + if not ok then + return nil, ("Failed to remove tombstone: %s"):format(err); + end + + return true, "User account forgotten"; + end; +}); +