# HG changeset patch # User Kim Alvefur # Date 1632507451 -7200 # Node ID bdabb0425d777571bd3ed6a864eab7ce9b2c1e2c # Parent a9ad287c3388ccd1005f40c4538659a1dbca9e74 core.moduleapi: Enable full JID origin queries with module:send_iq() Since we don't currently have hooks that includes type and id here, we need to check those attributes in the handlers. diff -r a9ad287c3388 -r bdabb0425d77 core/moduleapi.lua --- a/core/moduleapi.lua Fri Sep 24 20:12:16 2021 +0200 +++ b/core/moduleapi.lua Fri Sep 24 20:17:31 2021 +0200 @@ -20,6 +20,7 @@ local time_now = require "util.time".now; local format = require "util.format".format; local jid_node = require "util.jid".node; +local jid_resource = require "util.jid".resource; local t_insert, t_remove, t_concat = table.insert, table.remove, table.concat; local error, setmetatable, type = error, setmetatable, type; @@ -382,23 +383,31 @@ local event_type; if not jid_node(stanza.attr.from) then event_type = "host"; + elseif jid_resource(stanza.attr.from) then + event_type = "full"; else -- assume bare since we can't hook full jids event_type = "bare"; end local result_event = "iq-result/"..event_type.."/"..stanza.attr.id; local error_event = "iq-error/"..event_type.."/"..stanza.attr.id; local cache_key = event_type.."/"..stanza.attr.id; + if event_type == "full" then + result_event = "iq/" .. event_type; + error_event = "iq/" .. event_type; + end local p = promise.new(function (resolve, reject) local function result_handler(event) - if event.stanza.attr.from == stanza.attr.to then + local response = event.stanza; + if response.attr.type == "result" and response.attr.from == stanza.attr.to and response.attr.id == stanza.attr.id then resolve(event); return true; end end local function error_handler(event) - if event.stanza.attr.from == stanza.attr.to then + local response = event.stanza; + if response.attr.type == "error" and response.attr.from == stanza.attr.to and response.attr.id == stanza.attr.id then reject(errors.from_stanza(event.stanza, event)); return true; end