comparison mod_delegation/mod_delegation.lua @ 3271:7504f765e767

mod_delegation: Simplify iq handling by hooking on iq-get/ instead of iq/.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Fri, 24 Aug 2018 21:36:58 +0200
parents 82109d8eca41
children 36a9170352b5
comparison
equal deleted inserted replaced
3270:7776c9dc5f37 3271:7504f765e767
563 -- for now it's OK because Prosody is not returning anything on request on bare jid 563 -- for now it's OK because Prosody is not returning anything on request on bare jid
564 -- but to be properly done, any Prosody reply should be kept and managing entities items should be added (merged) to it. 564 -- but to be properly done, any Prosody reply should be kept and managing entities items should be added (merged) to it.
565 -- account-disco-items can't be cancelled (return value of hooks are not checked in mod_disco), so corountine needs 565 -- account-disco-items can't be cancelled (return value of hooks are not checked in mod_disco), so corountine needs
566 -- to be used with util.async (to get the IQ result, merge items then return from the event) 566 -- to be used with util.async (to get the IQ result, merge items then return from the event)
567 local origin, stanza = event.origin, event.stanza; 567 local origin, stanza = event.origin, event.stanza;
568 if stanza.attr.type ~= "get" then return; end
569 local node = stanza.tags[1].attr.node; 568 local node = stanza.tags[1].attr.node;
570 local username = jid_split(stanza.attr.to) or origin.username; 569 local username = jid_split(stanza.attr.to) or origin.username;
571 if not stanza.attr.to or is_contact_subscribed(username, module.host, jid_bare(stanza.attr.from)) then 570 if not stanza.attr.to or is_contact_subscribed(username, module.host, jid_bare(stanza.attr.from)) then
572 if node == nil or node == "" then 571 if node == nil or node == "" then
573 local ns_data = ns_delegations[_DISCO_REMAINING] 572 local ns_data = ns_delegations[_DISCO_REMAINING]
576 return true 575 return true
577 end 576 end
578 end 577 end
579 end 578 end
580 end 579 end
581 module:hook("iq/bare/http://jabber.org/protocol/disco#items:query", disco_items_hook, 100) 580 module:hook("iq-get/bare/http://jabber.org/protocol/disco#items:query", disco_items_hook, 100)
582 581
583 local function disco_items_raw_hook(event) 582 local function disco_items_raw_hook(event)
584 -- this method is called when account-disco-items-* event are not called 583 -- this method is called when account-disco-items-* event are not called
585 -- notably when a disco-item is done by an unsubscibed entity 584 -- notably when a disco-item is done by an unsubscibed entity
586 -- (i.e. an entity doing a disco#item on an entity without having 585 -- (i.e. an entity doing a disco#item on an entity without having