Software / code / prosody
Comparison
core/moduleapi.lua @ 10595:17bab303daf5
core.moduleapi: Hook correct event type in some cases
In rare cases, module.host can be a bare JID, in which case this test
did the wrong thing.
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Thu, 16 Jan 2020 16:30:26 +0100 |
| parent | 10576:f88f1151bc72 |
| child | 10705:2cffb5ce9f7a |
comparison
equal
deleted
inserted
replaced
| 10594:13d5fb74648f | 10595:17bab303daf5 |
|---|---|
| 17 local cache = require "util.cache"; | 17 local cache = require "util.cache"; |
| 18 local errors = require "util.error"; | 18 local errors = require "util.error"; |
| 19 local promise = require "util.promise"; | 19 local promise = require "util.promise"; |
| 20 local time_now = require "util.time".now; | 20 local time_now = require "util.time".now; |
| 21 local format = require "util.format".format; | 21 local format = require "util.format".format; |
| 22 local jid_node = require "util.jid".node; | |
| 22 | 23 |
| 23 local t_insert, t_remove, t_concat = table.insert, table.remove, table.concat; | 24 local t_insert, t_remove, t_concat = table.insert, table.remove, table.concat; |
| 24 local error, setmetatable, type = error, setmetatable, type; | 25 local error, setmetatable, type = error, setmetatable, type; |
| 25 local ipairs, pairs, select = ipairs, pairs, select; | 26 local ipairs, pairs, select = ipairs, pairs, select; |
| 26 local tonumber, tostring = tonumber, tostring; | 27 local tonumber, tostring = tonumber, tostring; |
| 377 end); | 378 end); |
| 378 self._iq_cache = iq_cache; | 379 self._iq_cache = iq_cache; |
| 379 end | 380 end |
| 380 | 381 |
| 381 local event_type; | 382 local event_type; |
| 382 if stanza.attr.from == self.host then | 383 if not jid_node(stanza.attr.from) then |
| 383 event_type = "host"; | 384 event_type = "host"; |
| 384 else -- assume bare since we can't hook full jids | 385 else -- assume bare since we can't hook full jids |
| 385 event_type = "bare"; | 386 event_type = "bare"; |
| 386 end | 387 end |
| 387 local result_event = "iq-result/"..event_type.."/"..stanza.attr.id; | 388 local result_event = "iq-result/"..event_type.."/"..stanza.attr.id; |