Software /
code /
prosody
Changeset
8341:910d3c3f60a6
mod_pep_plus: Use feature detection from pubsub.lib
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 18 Oct 2017 09:43:43 +0200 |
parents | 8340:7c1fb8c042dc |
children | 8342:0c0990a575de |
files | plugins/mod_pep_plus.lua |
diffstat | 1 files changed, 5 insertions(+), 32 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/mod_pep_plus.lua Wed Oct 18 09:38:45 2017 +0200 +++ b/plugins/mod_pep_plus.lua Wed Oct 18 09:43:43 2017 +0200 @@ -7,6 +7,7 @@ local calculate_hash = require "util.caps".calculate_hash; local is_contact_subscribed = require "core.rostermanager".is_contact_subscribed; local cache = require "util.cache"; +local set = require "util.set"; local xmlns_pubsub = "http://jabber.org/protocol/pubsub"; local xmlns_pubsub_event = "http://jabber.org/protocol/pubsub#event"; @@ -411,41 +412,12 @@ local origin, reply = event.origin, event.reply; reply:tag('identity', {category='pubsub', type='pep'}):up(); - reply:tag('feature', {var=xmlns_pubsub}):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_node_config = { "config-node" }; - node_defaults = { "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 - - -- Features not covered by the above - local more_features = { + local suppored_features = lib_pubsub.get_feature_set(service) + set.new{ + -- Features not covered by the above "access-presence", "auto-subscribe", "filtered-notifications", @@ -454,7 +426,8 @@ "presence-notifications", "presence-subscribe", }; - for _, feature in ipairs(more_features) do + + for feature in suppored_features do reply:tag('feature', {var=xmlns_pubsub.."#"..feature}):up(); end end);