prosodyctl: check certs: Warn about certificate expiry in the near future
[prosody.git] / core / moduleapi.lua
index 5817894f938e8d88dcad88f085107973ac6244fe..402c79275fe0456f2004c2b7aece035329d21dcc 100644 (file)
@@ -19,7 +19,8 @@ local st = require "util.stanza";
 
 local t_insert, t_remove, t_concat = table.insert, table.remove, table.concat;
 local error, setmetatable, type = error, setmetatable, type;
-local ipairs, pairs, select, unpack = ipairs, pairs, select, unpack;
+local ipairs, pairs, select = ipairs, pairs, select;
+local unpack = table.unpack or unpack; --luacheck: ignore 113
 local tonumber, tostring = tonumber, tostring;
 local require = require;
 
@@ -135,10 +136,7 @@ function api:wrap_global(event, handler)
 end
 
 function api:require(lib)
-       local f, n = pluginloader.load_code(self.name, lib..".lib.lua", self.environment);
-       if not f then
-               f, n = pluginloader.load_code(lib, lib..".lib.lua", self.environment);
-       end
+       local f, n = pluginloader.load_code_ext(self.name, lib, "lib.lua", self.environment);
        if not f then error("Failed to load plugin library '"..lib.."', error: "..n); end -- FIXME better error message
        return f();
 end
@@ -304,6 +302,20 @@ function api:get_option_inherited_set(name, ...)
        return value;
 end
 
+function api:get_option_path(name, default, parent)
+       if parent == nil then
+               parent = parent or self:get_directory();
+       elseif prosody.paths[parent] then
+               parent = prosody.paths[parent];
+       end
+       local value = self:get_option_string(name, default);
+       if value == nil then
+               return nil;
+       end
+       return resolve_relative_path(parent, value);
+end
+
+
 function api:context(host)
        return setmetatable({host=host or "*"}, {__index=self,__newindex=self});
 end