diff options
author | Kim Alvefur <zash@zash.se> | 2017-10-12 01:34:32 +0200 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2017-10-12 01:34:32 +0200 |
commit | 5d5432daf78f1fabb5ad9f54a1e096f092c8d81e (patch) | |
tree | e2ead2a4714cdd45202d847169db743615e0d2f2 /plugins/mod_pep_plus.lua | |
parent | 25b5ef2889ed4ef4fe2fd58143fa7042937ab449 (diff) | |
download | prosody-5d5432daf78f1fabb5ad9f54a1e096f092c8d81e.tar.gz prosody-5d5432daf78f1fabb5ad9f54a1e096f092c8d81e.zip |
mod_pep_plus: Advertise pubsub features in disco#info (code adapted from mod_pubsub)
Diffstat (limited to 'plugins/mod_pep_plus.lua')
-rw-r--r-- | plugins/mod_pep_plus.lua | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/plugins/mod_pep_plus.lua b/plugins/mod_pep_plus.lua index 323fbf8a..ce5fa231 100644 --- a/plugins/mod_pep_plus.lua +++ b/plugins/mod_pep_plus.lua @@ -409,9 +409,40 @@ module:hook("account-disco-info-node", function(event) end); module:hook("account-disco-info", function(event) - local reply = event.reply; + local origin, reply = event.origin, event.reply; + reply:tag('identity', {category='pubsub', type='pep'}):up(); - reply:tag('feature', {var='http://jabber.org/protocol/pubsub#publish'}):up(); + + local username = jid_split(reply.attr.from) or origin.username; + local service = get_pep_service(username); + + local feature_map = { + create = { "create-nodes", "instant-nodes", "item-ids" }; + retract = { "delete-items", "retract-items" }; + purge = { "purge-nodes" }; + publish = { "publish", service.config.autocreate_on_publish and "auto-create" }; + delete = { "delete-nodes" }; + get_items = { "retrieve-items" }; + add_subscription = { "subscribe" }; + get_subscriptions = { "retrieve-subscriptions" }; + set_configure = { "config-node" }; + get_default = { "retrieve-default" }; + }; + + for method, features in pairs(feature_map) do + if service[method] then + for _, feature in ipairs(features) do + if feature then + reply:tag('feature', {var=xmlns_pubsub.."#"..feature}):up(); + end + end + end + end + for affiliation in pairs(service.config.capabilities) do + if affiliation ~= "none" and affiliation ~= "owner" then + reply:tag('feature', {var=xmlns_pubsub.."#"..affiliation.."-affiliation"}):up(); + end + end end); module:hook("account-disco-items-node", function(event) |