aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2017-10-12 01:34:32 +0200
committerKim Alvefur <zash@zash.se>2017-10-12 01:34:32 +0200
commitca04e5900d557af19d1cd4695e1041bb372027e6 (patch)
tree849ab4982f062e4073360a67cfa782412f3d6538
parent93ee5c657bd88017ddd6081151b0de8253964a06 (diff)
downloadprosody-im-server-ca04e5900d557af19d1cd4695e1041bb372027e6.tar
prosody-im-server-ca04e5900d557af19d1cd4695e1041bb372027e6.zip
mod_pep_plus: Advertise pubsub features in disco#info (code adapted from mod_pubsub)
-rw-r--r--plugins/mod_pep_plus.lua35
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)