Changeset

9230:711fea229e48

util.pubsub: Add 'service' field to all events
author Matthew Wild <mwild1@gmail.com>
date Mon, 27 Aug 2018 14:07:28 +0100
parents 9229:1338b84c0566
children 9231:3d12b4f41b23
files util/pubsub.lua
diffstat 1 files changed, 7 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/util/pubsub.lua	Fri Aug 24 21:04:27 2018 +0200
+++ b/util/pubsub.lua	Mon Aug 27 14:07:28 2018 +0100
@@ -321,7 +321,7 @@
 		end
 	end
 
-	self.events.fire_event("subscription-added", { node = node, jid = jid, normalized_jid = normal_jid, options = options });
+	self.events.fire_event("subscription-added", { service = self, node = node, jid = jid, normalized_jid = normal_jid, options = options });
 	return true;
 end
 
@@ -373,7 +373,7 @@
 		end
 	end
 
-	self.events.fire_event("subscription-removed", { node = node, jid = jid, normalized_jid = normal_jid });
+	self.events.fire_event("subscription-removed", { service = self, node = node, jid = jid, normalized_jid = normal_jid });
 	return true;
 end
 
@@ -422,7 +422,7 @@
 	end
 
 	self.data[node] = self.config.itemstore(self.nodes[node].config, node);
-	self.events.fire_event("node-created", { node = node, actor = actor });
+	self.events.fire_event("node-created", { service = self, node = node, actor = actor });
 	if actor ~= true then
 		local ok, err = self:set_affiliation(node, true, actor, "owner");
 		if not ok then
@@ -459,7 +459,7 @@
 		end
 	end
 
-	self.events.fire_event("node-deleted", { node = node, actor = actor });
+	self.events.fire_event("node-deleted", { service = self, node = node, actor = actor });
 	self.config.broadcaster("delete", node, node_obj.subscribers, nil, actor, node_obj, self);
 	return true;
 end
@@ -517,7 +517,7 @@
 		return nil, "internal-server-error";
 	end
 	if type(ok) == "string" then id = ok; end
-	local event_data = { node = node, actor = actor, id = id, item = item };
+	local event_data = { service = self, node = node, actor = actor, id = id, item = item };
 	self.events.fire_event("item-published/"..node, event_data);
 	self.events.fire_event("item-published", event_data);
 	self.config.broadcaster("items", node, node_obj.subscribers, item, actor, node_obj, self);
@@ -538,7 +538,7 @@
 	if not ok then
 		return nil, "internal-server-error";
 	end
-	self.events.fire_event("item-retracted", { node = node, actor = actor, id = id });
+	self.events.fire_event("item-retracted", { service = self, node = node, actor = actor, id = id });
 	if retract then
 		self.config.broadcaster("retract", node, node_obj.subscribers, retract, actor, node_obj, self);
 	end
@@ -560,7 +560,7 @@
 	else
 		self.data[node] = self.config.itemstore(self.nodes[node].config, node);
 	end
-	self.events.fire_event("node-purged", { node = node, actor = actor });
+	self.events.fire_event("node-purged", { service = self, node = node, actor = actor });
 	if notify then
 		self.config.broadcaster("purge", node, node_obj.subscribers, nil, actor, node_obj, self);
 	end