Mercurial > prosody-hg
comparison util/pubsub.lua @ 13549:3b357ab6b6eb
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.
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Fri, 08 Nov 2024 02:11:00 +0100 |
| parents | 88cab98aa28c |
| children | c8458864dcea 888d0c52db41 |
comparison
equal
deleted
inserted
replaced
| 13548:84ee435f284e | 13549:3b357ab6b6eb |
|---|---|
| 9 broadcaster = function () end; | 9 broadcaster = function () end; |
| 10 subscriber_filter = function (subs) return subs end; | 10 subscriber_filter = function (subs) return subs end; |
| 11 itemcheck = function () return true; end; | 11 itemcheck = function () return true; end; |
| 12 get_affiliation = function () end; | 12 get_affiliation = function () end; |
| 13 normalize_jid = function (jid) return jid; end; | 13 normalize_jid = function (jid) return jid; end; |
| 14 metadata_subset = {}; | |
| 14 capabilities = { | 15 capabilities = { |
| 15 outcast = { | 16 outcast = { |
| 16 create = false; | 17 create = false; |
| 17 publish = false; | 18 publish = false; |
| 18 retract = false; | 19 retract = false; |
| 43 subscribe = true; | 44 subscribe = true; |
| 44 unsubscribe = true; | 45 unsubscribe = true; |
| 45 get_subscription = true; | 46 get_subscription = true; |
| 46 get_subscriptions = true; | 47 get_subscriptions = true; |
| 47 get_items = false; | 48 get_items = false; |
| 49 get_metadata = true; | |
| 48 | 50 |
| 49 subscribe_other = false; | 51 subscribe_other = false; |
| 50 unsubscribe_other = false; | 52 unsubscribe_other = false; |
| 51 get_subscription_other = false; | 53 get_subscription_other = false; |
| 52 get_subscriptions_other = false; | 54 get_subscriptions_other = false; |
| 65 subscribe = true; | 67 subscribe = true; |
| 66 unsubscribe = true; | 68 unsubscribe = true; |
| 67 get_subscription = true; | 69 get_subscription = true; |
| 68 get_subscriptions = true; | 70 get_subscriptions = true; |
| 69 get_items = true; | 71 get_items = true; |
| 72 get_metadata = true; | |
| 70 | 73 |
| 71 subscribe_other = false; | 74 subscribe_other = false; |
| 72 unsubscribe_other = false; | 75 unsubscribe_other = false; |
| 73 get_subscription_other = false; | 76 get_subscription_other = false; |
| 74 get_subscriptions_other = false; | 77 get_subscriptions_other = false; |
| 88 subscribe = true; | 91 subscribe = true; |
| 89 unsubscribe = true; | 92 unsubscribe = true; |
| 90 get_subscription = true; | 93 get_subscription = true; |
| 91 get_subscriptions = true; | 94 get_subscriptions = true; |
| 92 get_items = true; | 95 get_items = true; |
| 96 get_metadata = true; | |
| 93 | 97 |
| 94 subscribe_other = false; | 98 subscribe_other = false; |
| 95 unsubscribe_other = false; | 99 unsubscribe_other = false; |
| 96 get_subscription_other = false; | 100 get_subscription_other = false; |
| 97 get_subscriptions_other = false; | 101 get_subscriptions_other = false; |
| 113 subscribe = true; | 117 subscribe = true; |
| 114 unsubscribe = true; | 118 unsubscribe = true; |
| 115 get_subscription = true; | 119 get_subscription = true; |
| 116 get_subscriptions = true; | 120 get_subscriptions = true; |
| 117 get_items = true; | 121 get_items = true; |
| 122 get_metadata = true; | |
| 118 | 123 |
| 119 | 124 |
| 120 subscribe_other = true; | 125 subscribe_other = true; |
| 121 unsubscribe_other = true; | 126 unsubscribe_other = true; |
| 122 get_subscription_other = true; | 127 get_subscription_other = true; |
| 870 end | 875 end |
| 871 | 876 |
| 872 return true, config_table; | 877 return true, config_table; |
| 873 end | 878 end |
| 874 | 879 |
| 880 function service:get_node_metadata(node, actor) | |
| 881 if not self:may(node, actor, "get_metadata") then | |
| 882 return false, "forbidden"; | |
| 883 end | |
| 884 | |
| 885 local ok, config = self:get_node_config(node, true); | |
| 886 if not ok then return ok, config; end | |
| 887 local meta = {}; | |
| 888 for _, k in ipairs(self.config.metadata_subset) do | |
| 889 meta[k] = config[k]; | |
| 890 end | |
| 891 return true, meta; | |
| 892 end | |
| 893 | |
| 875 return { | 894 return { |
| 876 new = new; | 895 new = new; |
| 877 }; | 896 }; |
