From ca08584d742a8bca8c93547d189529752a8cc23d Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Thu, 4 Nov 2021 01:00:06 +0100 Subject: mod_pep: Wipe pubsub service on user deletion Data is already wiped from storage, but this ensures everything is properly unsubscribed, possibly with notifications etc. Clears recipient cache as well, since it is no longer relevant. --- plugins/mod_pep.lua | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/plugins/mod_pep.lua b/plugins/mod_pep.lua index a96bb1aa..4ee3db5e 100644 --- a/plugins/mod_pep.lua +++ b/plugins/mod_pep.lua @@ -467,3 +467,18 @@ module:hook("account-disco-items", function(event) reply:tag("item", { jid = user_bare, node = node, name = node_obj.config.title }):up(); end end); + +module:hook_global("user-deleted", function(event) + if event.host ~= host then return end + local username = event.username; + local service = services[username]; + if not service then return end + for node in pairs(service.nodes) do service:delete(node, true); end + + local item = pep_service_items[username]; + pep_service_items[username] = nil; + if item then module:remove_item("pep-service", item); end + + recipients[username] = nil; +end); + -- cgit v1.2.3