mod_pubsub: Boilerplate checks for affiliation retrieval
authorKim Alvefur <zash@zash.se>
Tue, 26 Jun 2018 19:30:28 +0200
changeset 8936 6d3ecf9e8277
parent 8935 12a9731aef0b
child 8937 365bcf899093
mod_pubsub: Boilerplate checks for affiliation retrieval
plugins/mod_pubsub/pubsub.lib.lua
--- 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
 --]]