Software /
code /
prosody
Comparison
plugins/mod_pep_plus.lua @ 8321:73ff49a42ea8
mod_pep_plus: Advertise nodes with the correct JID (missed in ec605946e597) (thanks lovetox)
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 13 Oct 2017 19:55:33 +0200 |
parent | 8320:fe5eaf4ed631 |
child | 8331:8df0eaa564f0 |
comparison
equal
deleted
inserted
replaced
8320:fe5eaf4ed631 | 8321:73ff49a42ea8 |
---|---|
454 end); | 454 end); |
455 | 455 |
456 module:hook("account-disco-items-node", function(event) | 456 module:hook("account-disco-items-node", function(event) |
457 local reply, stanza, origin = event.reply, event.stanza, event.origin; | 457 local reply, stanza, origin = event.reply, event.stanza, event.origin; |
458 local node = event.node; | 458 local node = event.node; |
459 local service_name = origin.username; | 459 local is_self = stanza.attr.to == nil; |
460 if stanza.attr.to ~= nil then | 460 local user_bare = jid_bare(stanza.attr.to); |
461 service_name = jid_split(stanza.attr.to); | 461 local username = jid_split(stanza.attr.to); |
462 end | 462 if is_self then |
463 local service = get_pep_service(service_name); | 463 username = origin.username; |
464 user_bare = jid_join(username, host); | |
465 end | |
466 local service = get_pep_service(username); | |
464 local ok, ret = service:get_items(node, jid_bare(stanza.attr.from) or true); | 467 local ok, ret = service:get_items(node, jid_bare(stanza.attr.from) or true); |
465 if not ok then return; end | 468 if not ok then return; end |
466 event.exists = true; | 469 event.exists = true; |
467 for _, id in ipairs(ret) do | 470 for _, id in ipairs(ret) do |
468 reply:tag("item", { jid = service_name, name = id }):up(); | 471 reply:tag("item", { jid = user_bare, name = id }):up(); |
469 end | 472 end |
470 end); | 473 end); |
471 | 474 |
472 module:hook("account-disco-items", function(event) | 475 module:hook("account-disco-items", function(event) |
473 local reply, stanza, origin = event.reply, event.stanza, event.origin; | 476 local reply, stanza, origin = event.reply, event.stanza, event.origin; |
474 | 477 |
475 local service_name = origin.username; | 478 local is_self = stanza.attr.to == nil; |
476 if stanza.attr.to ~= nil then | 479 local user_bare = jid_bare(stanza.attr.to); |
477 service_name = jid_split(stanza.attr.to); | 480 local username = jid_split(stanza.attr.to); |
478 end | 481 if is_self then |
479 local service = get_pep_service(service_name); | 482 username = origin.username; |
483 user_bare = jid_join(username, host); | |
484 end | |
485 local service = get_pep_service(username); | |
486 | |
480 local ok, ret = service:get_nodes(jid_bare(stanza.attr.from)); | 487 local ok, ret = service:get_nodes(jid_bare(stanza.attr.from)); |
481 if not ok then return; end | 488 if not ok then return; end |
482 | 489 |
483 for node, node_obj in pairs(ret) do | 490 for node, node_obj in pairs(ret) do |
484 reply:tag("item", { jid = service_name, node = node, name = node_obj.config.name }):up(); | 491 reply:tag("item", { jid = user_bare, node = node, name = node_obj.config.name }):up(); |
485 end | 492 end |
486 end); | 493 end); |