aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorMarco Cirillo <maranda@lightwitch.org>2013-04-01 23:44:28 +0000
committerMarco Cirillo <maranda@lightwitch.org>2013-04-01 23:44:28 +0000
commitfd14557245f2033db9c282211f29f5562bc40452 (patch)
tree9282bd448c104f21cffcd60bcd413648cf09c6e8 /core
parent4453095de2be99c78b1cede797cb0c468458e84d (diff)
downloadprosody-fd14557245f2033db9c282211f29f5562bc40452.tar.gz
prosody-fd14557245f2033db9c282211f29f5562bc40452.zip
moduleapi: have get_host_items wrap on get_items from modulemanager, also add has_{feature/identity} to the API.
Diffstat (limited to 'core')
-rw-r--r--core/moduleapi.lua32
1 files changed, 15 insertions, 17 deletions
diff --git a/core/moduleapi.lua b/core/moduleapi.lua
index f9701471..de900bf0 100644
--- a/core/moduleapi.lua
+++ b/core/moduleapi.lua
@@ -62,6 +62,20 @@ end
function api:add_extension(data)
self:add_item("extension", data);
end
+function api:has_feature(xmlns)
+ for _, feature in ipairs(self:get_host_items("feature")) do
+ if feature == xmlns then return true; end
+ end
+ return false;
+end
+function api:has_identity(category, type, name)
+ for _, id in ipairs(self:get_host_items("identity")) do
+ if id.category == category and id.type == type and id.name == name then
+ return true;
+ end
+ end
+ return false;
+end
function api:fire_event(...)
return (hosts[self.host] or prosody).events.fire_event(...);
@@ -271,23 +285,7 @@ function api:remove_item(key, value)
end
function api:get_host_items(key)
- local result = {};
- for mod_name, module in pairs(modulemanager.get_modules(self.host)) do
- module = module.module;
- if module.items then
- for _, item in ipairs(module.items[key] or NULL) do
- t_insert(result, item);
- end
- end
- end
- for mod_name, module in pairs(modulemanager.get_modules("*")) do
- module = module.module;
- if module.items then
- for _, item in ipairs(module.items[key] or NULL) do
- t_insert(result, item);
- end
- end
- end
+ local result = modulemanager.get_items(key, self.host) or {};
return result;
end