# HG changeset patch # User Kim Alvefur # Date 1530034228 -7200 # Node ID 6d3ecf9e8277832f34acec3696fa7acb79eb630e # Parent 12a9731aef0bc137bd0a9dfdab761b0adfaa9c26 mod_pubsub: Boilerplate checks for affiliation retrieval diff -r 12a9731aef0b -r 6d3ecf9e8277 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 --]]