diff options
author | Matthew Wild <mwild1@gmail.com> | 2013-04-03 13:53:21 +0100 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2013-04-03 13:53:21 +0100 |
commit | a5ccb8a860924f48570242e468267885137e3e9a (patch) | |
tree | bf22e9f39d9ccaa98ba9f214cfa01d7c3408d46a /core/moduleapi.lua | |
parent | 1ea4d9ab7bde60b904192718247d49aa1337a18e (diff) | |
parent | 1728207c6bb7f3955535ba4a2c1c6fde8e624ed8 (diff) | |
download | prosody-a5ccb8a860924f48570242e468267885137e3e9a.tar.gz prosody-a5ccb8a860924f48570242e468267885137e3e9a.zip |
Merge 0.9->trunk
Diffstat (limited to 'core/moduleapi.lua')
-rw-r--r-- | core/moduleapi.lua | 32 |
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 |