Changeset

8933:6d3ecf9e8277

mod_pubsub: Boilerplate checks for affiliation retrieval
author Kim Alvefur <zash@zash.se>
date Tue, 26 Jun 2018 19:30:28 +0200
parents 8932:12a9731aef0b
children 8934:365bcf899093
files plugins/mod_pubsub/pubsub.lib.lua
diffstat 1 files changed, 17 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_pubsub/pubsub.lib.lua	Tue Jun 26 19:28:37 2018 +0200
+++ b/plugins/mod_pubsub/pubsub.lib.lua	Tue Jun 26 19:30:28 2018 +0200
@@ -454,10 +454,26 @@
 	return true;
 end
 
---[[ TODO
 function handlers.owner_get_affiliations(origin, stanza, affiliations, service)
+	local node = affiliations.attr.node;
+	if not node then
+		origin.send(pubsub_error_reply(stanza, "nodeid-required"));
+		return true;
+	end
+	if not service:may(node, stanza.attr.from, "set_affiliation") then
+		origin.send(pubsub_error_reply(stanza, "forbidden"));
+		return true;
+	end
+
+	local reply = st.reply(stanza)
+		:tag("pubsub", { xmlns = xmlns_pubsub_owner })
+			:tag("affiliations", { node = node });
+
+	origin.send(reply);
+	return true;
 end
 
+--[[ TODO
 function handlers.owner_set_affiliations(origin, stanza, affiliations, service)
 end
 --]]