aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2017-10-13 19:55:33 +0200
committerKim Alvefur <zash@zash.se>2017-10-13 19:55:33 +0200
commit9f3c47fb9f60e9555afe28994aca88e0ce250a82 (patch)
treeb8d65d846878b885c84632179470b0b4ea6969db
parentbfd1f93fbf82b038852ee1a21acac1e125a557d4 (diff)
downloadprosody-9f3c47fb9f60e9555afe28994aca88e0ce250a82.tar.gz
prosody-9f3c47fb9f60e9555afe28994aca88e0ce250a82.zip
mod_pep_plus: Advertise nodes with the correct JID (missed in ec605946e597) (thanks lovetox)
-rw-r--r--plugins/mod_pep_plus.lua27
1 files changed, 17 insertions, 10 deletions
diff --git a/plugins/mod_pep_plus.lua b/plugins/mod_pep_plus.lua
index db42fbc9..f8fc987f 100644
--- a/plugins/mod_pep_plus.lua
+++ b/plugins/mod_pep_plus.lua
@@ -456,31 +456,38 @@ end);
module:hook("account-disco-items-node", function(event)
local reply, stanza, origin = event.reply, event.stanza, event.origin;
local node = event.node;
- local service_name = origin.username;
- if stanza.attr.to ~= nil then
- service_name = jid_split(stanza.attr.to);
+ local is_self = stanza.attr.to == nil;
+ local user_bare = jid_bare(stanza.attr.to);
+ local username = jid_split(stanza.attr.to);
+ if is_self then
+ username = origin.username;
+ user_bare = jid_join(username, host);
end
- local service = get_pep_service(service_name);
+ local service = get_pep_service(username);
local ok, ret = service:get_items(node, jid_bare(stanza.attr.from) or true);
if not ok then return; end
event.exists = true;
for _, id in ipairs(ret) do
- reply:tag("item", { jid = service_name, name = id }):up();
+ reply:tag("item", { jid = user_bare, name = id }):up();
end
end);
module:hook("account-disco-items", function(event)
local reply, stanza, origin = event.reply, event.stanza, event.origin;
- local service_name = origin.username;
- if stanza.attr.to ~= nil then
- service_name = jid_split(stanza.attr.to);
+ local is_self = stanza.attr.to == nil;
+ local user_bare = jid_bare(stanza.attr.to);
+ local username = jid_split(stanza.attr.to);
+ if is_self then
+ username = origin.username;
+ user_bare = jid_join(username, host);
end
- local service = get_pep_service(service_name);
+ local service = get_pep_service(username);
+
local ok, ret = service:get_nodes(jid_bare(stanza.attr.from));
if not ok then return; end
for node, node_obj in pairs(ret) do
- reply:tag("item", { jid = service_name, node = node, name = node_obj.config.name }):up();
+ reply:tag("item", { jid = user_bare, node = node, name = node_obj.config.name }):up();
end
end);