Software /
code /
prosody
Comparison
plugins/mod_pubsub/mod_pubsub.lua @ 8340:7c1fb8c042dc
mod_pubsub: Move service feature dection to pubsub.lib to allow reuse
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 18 Oct 2017 09:38:45 +0200 |
parent | 8339:4fce6bc0719f |
child | 8503:3b86134c56ea |
comparison
equal
deleted
inserted
replaced
8339:4fce6bc0719f | 8340:7c1fb8c042dc |
---|---|
58 end | 58 end |
59 | 59 |
60 module:hook("iq/host/"..xmlns_pubsub..":pubsub", handle_pubsub_iq); | 60 module:hook("iq/host/"..xmlns_pubsub..":pubsub", handle_pubsub_iq); |
61 module:hook("iq/host/"..xmlns_pubsub_owner..":pubsub", handle_pubsub_iq); | 61 module:hook("iq/host/"..xmlns_pubsub_owner..":pubsub", handle_pubsub_iq); |
62 | 62 |
63 local feature_map = { | |
64 create = { "create-nodes", "instant-nodes", "item-ids", "create-and-configure" }; | |
65 retract = { "delete-items", "retract-items" }; | |
66 purge = { "purge-nodes" }; | |
67 publish = { "publish", autocreate_on_publish and "auto-create" }; | |
68 delete = { "delete-nodes" }; | |
69 get_items = { "retrieve-items" }; | |
70 add_subscription = { "subscribe" }; | |
71 get_subscriptions = { "retrieve-subscriptions" }; | |
72 set_node_config = { "config-node" }; | |
73 node_defaults = { "retrieve-default" }; | |
74 }; | |
75 | |
76 local function add_disco_features_from_service(service) | 63 local function add_disco_features_from_service(service) |
77 for method, features in pairs(feature_map) do | 64 for feature in lib_pubsub.get_feature_set(service) do |
78 if service[method] then | 65 module:add_feature(xmlns_pubsub.."#"..feature); |
79 for _, feature in ipairs(features) do | |
80 if feature then | |
81 module:add_feature(xmlns_pubsub.."#"..feature); | |
82 end | |
83 end | |
84 end | |
85 end | |
86 for affiliation in pairs(service.config.capabilities) do | |
87 if affiliation ~= "none" and affiliation ~= "owner" then | |
88 module:add_feature(xmlns_pubsub.."#"..affiliation.."-affiliation"); | |
89 end | |
90 end | 66 end |
91 end | 67 end |
92 | 68 |
93 module:hook("host-disco-info-node", function (event) | 69 module:hook("host-disco-info-node", function (event) |
94 local stanza, reply, node = event.stanza, event.reply, event.node; | 70 local stanza, reply, node = event.stanza, event.reply, event.node; |