Mercurial > prosody-hg
changeset 14212:55a7143a58ec
mod_tombstones: Add shell commands for listing and clearing tombstones
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Fri, 05 Jun 2026 16:24:55 +0100 |
| parents | a8ce6f45ba35 |
| children | 3870f944dec4 |
| files | plugins/mod_tombstones.lua |
| diffstat | 1 files changed, 47 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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; +}); +
