# HG changeset patch # User Kim Alvefur # Date 1736321614 -3600 # Node ID a4217361c1c6ee172b8207e3631165d0008a4c43 # Parent 6e5124f72e9a7053992e1acd4e4241577fc9d891 core.moduleapi: Include source modules when handling items This improves consistency. Previously the 'source' field was only provided in the original event when an item was added. It is used to report the name of the module providing the item in a few places. Also considered adding a new API to modulemanager returning a mapping of items per module and then using that here. diff -r 6e5124f72e9a -r a4217361c1c6 core/moduleapi.lua --- a/core/moduleapi.lua Wed Jan 08 08:11:02 2025 +0100 +++ b/core/moduleapi.lua Wed Jan 08 08:33:34 2025 +0100 @@ -431,8 +431,16 @@ self:hook("item-added/"..item_type, added_cb); self:hook("item-removed/"..item_type, removed_cb); if existing ~= false then - for _, item in ipairs(self:get_host_items(item_type)) do - added_cb({ item = item }); + local modulemanager = require"prosody.core.modulemanager"; + local modules = modulemanager.get_modules(self.host); + + for _, module in pairs(modules) do + local mod = module.module; + if mod.items and mod.items[item_type] then + for _, item in ipairs(mod.items[item_type]) do + added_cb({ source = mod; item = item }); + end + end end end end