Changeset

12089:76b4e3f12b53 0.11 0.11.11

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.
author Kim Alvefur <zash@zash.se>
date Thu, 04 Nov 2021 01:00:06 +0100
parents 12088:e5028f6eb599
children 12090:e77735354fad
files plugins/mod_pep.lua
diffstat 1 files changed, 15 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_pep.lua	Thu Nov 04 00:55:59 2021 +0100
+++ b/plugins/mod_pep.lua	Thu Nov 04 01:00:06 2021 +0100
@@ -467,3 +467,18 @@
 		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);
+