aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2011-08-29 13:09:29 -0400
committerMatthew Wild <mwild1@gmail.com>2011-08-29 13:09:29 -0400
commitbe9a85a08af059ee16b242cdaba01b539d14ff32 (patch)
tree8dab7002b1648d6c3aad5afbb3a02fcff216c886 /core
parentcfd622372fcdfb31f2dc400be443f7266032f444 (diff)
downloadprosody-be9a85a08af059ee16b242cdaba01b539d14ff32.tar.gz
prosody-be9a85a08af059ee16b242cdaba01b539d14ff32.zip
modulemanager: Add module:handle_items() to allow a module to more easily handle a list of items on a host
Diffstat (limited to 'core')
-rw-r--r--core/modulemanager.lua10
1 files changed, 10 insertions, 0 deletions
diff --git a/core/modulemanager.lua b/core/modulemanager.lua
index d0a0f982..b89c5af3 100644
--- a/core/modulemanager.lua
+++ b/core/modulemanager.lua
@@ -453,4 +453,14 @@ function api:get_host_items(key)
return result;
end
+function api:handle_items(type, added_cb, removed_cb, existing)
+ self:hook("item-added/"..type, added_cb);
+ self:hook("item-removed/"..type, removed_cb);
+ if existing ~= false then
+ for _, item in ipairs(self:get_host_items(type)) do
+ added_cb({ item = item });
+ end
+ end
+end
+
return _M;