Software /
code /
prosody
Comparison
plugins/mod_pubsub/mod_pubsub.lua @ 8980:4d2738b99b07
mod_pubsub: Move service discovery to pubsub.lib to allow reuse
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 06 Jul 2018 18:00:50 +0200 |
parent | 8957:21ae6cb20dcf |
child | 9039:0124e5ec1556 |
comparison
equal
deleted
inserted
replaced
8979:6897b2e18bdf | 8980:4d2738b99b07 |
---|---|
86 module:add_feature(xmlns_pubsub.."#"..feature); | 86 module:add_feature(xmlns_pubsub.."#"..feature); |
87 end | 87 end |
88 end | 88 end |
89 | 89 |
90 module:hook("host-disco-info-node", function (event) | 90 module:hook("host-disco-info-node", function (event) |
91 local stanza, reply, node = event.stanza, event.reply, event.node; | 91 return lib_pubsub.handle_disco_info_node(event, service); |
92 local ok, ret = service:get_nodes(stanza.attr.from); | |
93 if not ok or not ret[node] then | |
94 return; | |
95 end | |
96 event.exists = true; | |
97 reply:tag("identity", { category = "pubsub", type = "leaf" }); | |
98 end); | 92 end); |
99 | 93 |
100 module:hook("host-disco-items-node", function (event) | 94 module:hook("host-disco-items-node", function (event) |
101 local stanza, reply, node = event.stanza, event.reply, event.node; | 95 return lib_pubsub.handle_disco_items_node(event, service); |
102 local ok, ret = service:get_items(node, stanza.attr.from); | |
103 if not ok then | |
104 return; | |
105 end | |
106 | |
107 for _, id in ipairs(ret) do | |
108 reply:tag("item", { jid = module.host, name = id }):up(); | |
109 end | |
110 event.exists = true; | |
111 end); | 96 end); |
112 | 97 |
113 | 98 |
114 module:hook("host-disco-items", function (event) | 99 module:hook("host-disco-items", function (event) |
115 local stanza, reply = event.stanza, event.reply; | 100 local stanza, reply = event.stanza, event.reply; |