From bddb37e08b18f8f860bfa3cf77054deb1ce00e6d Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Tue, 26 Jun 2018 19:30:28 +0200 Subject: mod_pubsub: Boilerplate checks for affiliation retrieval --- plugins/mod_pubsub/pubsub.lib.lua | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/plugins/mod_pubsub/pubsub.lib.lua b/plugins/mod_pubsub/pubsub.lib.lua index c9ebfdb4..b030abbd 100644 --- a/plugins/mod_pubsub/pubsub.lib.lua +++ b/plugins/mod_pubsub/pubsub.lib.lua @@ -454,10 +454,26 @@ function handlers.owner_get_default(origin, stanza, default, service) -- luachec 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 --]] -- cgit v1.2.3