aboutsummaryrefslogtreecommitdiffstats
path: root/util/pubsub.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2024-11-08 02:11:00 +0100
committerKim Alvefur <zash@zash.se>2024-11-08 02:11:00 +0100
commit9005d35b4850dcde6d8fb4cba713f50a641a5b88 (patch)
tree476bb4bebfb4cf984b896077b5dc897454f3e0cb /util/pubsub.lua
parentef342f9734a4141b92b280040fd6180f4a30a5ae (diff)
downloadprosody-9005d35b4850dcde6d8fb4cba713f50a641a5b88.tar.gz
prosody-9005d35b4850dcde6d8fb4cba713f50a641a5b88.zip
util.pubsub: Add method returning subset of config as metadata
Allows granting read only access to other sets of users using a separate access control capability, which makes sense as some properties may be intended to be public but read-only.
Diffstat (limited to 'util/pubsub.lua')
-rw-r--r--util/pubsub.lua19
1 files changed, 19 insertions, 0 deletions
diff --git a/util/pubsub.lua b/util/pubsub.lua
index 11ed4e1c..d6779736 100644
--- a/util/pubsub.lua
+++ b/util/pubsub.lua
@@ -11,6 +11,7 @@ local default_config = {
itemcheck = function () return true; end;
get_affiliation = function () end;
normalize_jid = function (jid) return jid; end;
+ metadata_subset = {};
capabilities = {
outcast = {
create = false;
@@ -45,6 +46,7 @@ local default_config = {
get_subscription = true;
get_subscriptions = true;
get_items = false;
+ get_metadata = true;
subscribe_other = false;
unsubscribe_other = false;
@@ -67,6 +69,7 @@ local default_config = {
get_subscription = true;
get_subscriptions = true;
get_items = true;
+ get_metadata = true;
subscribe_other = false;
unsubscribe_other = false;
@@ -90,6 +93,7 @@ local default_config = {
get_subscription = true;
get_subscriptions = true;
get_items = true;
+ get_metadata = true;
subscribe_other = false;
unsubscribe_other = false;
@@ -115,6 +119,7 @@ local default_config = {
get_subscription = true;
get_subscriptions = true;
get_items = true;
+ get_metadata = true;
subscribe_other = true;
@@ -872,6 +877,20 @@ function service:get_node_config(node, actor) --> (true, config) or (false, err)
return true, config_table;
end
+function service:get_node_metadata(node, actor)
+ if not self:may(node, actor, "get_metadata") then
+ return false, "forbidden";
+ end
+
+ local ok, config = self:get_node_config(node, true);
+ if not ok then return ok, config; end
+ local meta = {};
+ for _, k in ipairs(self.config.metadata_subset) do
+ meta[k] = config[k];
+ end
+ return true, meta;
+end
+
return {
new = new;
};