From c3d7d52f0df686f7cfd5ee6c6474edf6e206c5c0 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Thu, 16 Mar 2017 20:46:06 +0100 Subject: plugins/various: Use type-specific config API --- plugins/mod_admin_telnet.lua | 4 ++-- plugins/mod_disco.lua | 2 +- plugins/mod_http_files.lua | 2 +- plugins/mod_version.lua | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) (limited to 'plugins') diff --git a/plugins/mod_admin_telnet.lua b/plugins/mod_admin_telnet.lua index b24adcf9..04e93d7e 100644 --- a/plugins/mod_admin_telnet.lua +++ b/plugins/mod_admin_telnet.lua @@ -1111,7 +1111,7 @@ function def_env.http:list() for host in pairs(prosody.hosts) do local http_apps = modulemanager.get_items("http-provider", host); if #http_apps > 0 then - local http_host = module:context(host):get_option("http_host"); + local http_host = module:context(host):get_option_string("http_host"); print("HTTP endpoints on "..host..(http_host and (" (using "..http_host.."):") or ":")); for _, provider in ipairs(http_apps) do local url = module:context(host):http_url(provider.name); @@ -1121,7 +1121,7 @@ function def_env.http:list() end end - local default_host = module:get_option("http_default_host"); + local default_host = module:get_option_string("http_default_host"); if not default_host then print("HTTP requests to unknown hosts will return 404 Not Found"); else diff --git a/plugins/mod_disco.lua b/plugins/mod_disco.lua index c9d4a9df..517fcaec 100644 --- a/plugins/mod_disco.lua +++ b/plugins/mod_disco.lua @@ -13,7 +13,7 @@ local jid_bare = require "util.jid".bare; local st = require "util.stanza" local calculate_hash = require "util.caps".calculate_hash; -local disco_items = module:get_option("disco_items") or {}; +local disco_items = module:get_option_array("disco_items", {}) do -- validate disco_items for _, item in ipairs(disco_items) do local err; diff --git a/plugins/mod_http_files.lua b/plugins/mod_http_files.lua index ab2f3966..7735cfbb 100644 --- a/plugins/mod_http_files.lua +++ b/plugins/mod_http_files.lua @@ -19,7 +19,7 @@ local path_sep = package.config:sub(1,1); local base_path = module:get_option_string("http_files_dir", module:get_option_string("http_path")); local cache_size = module:get_option_number("http_files_cache_size", 128); local cache_max_file_size = module:get_option_number("http_files_cache_max_file_size", 4096); -local dir_indices = module:get_option("http_index_files", { "index.html", "index.htm" }); +local dir_indices = module:get_option_array("http_index_files", { "index.html", "index.htm" }); local directory_index = module:get_option_boolean("http_dir_listing"); local mime_map = module:shared("/*/http_files/mime").types; diff --git a/plugins/mod_version.lua b/plugins/mod_version.lua index be244beb..7f045415 100644 --- a/plugins/mod_version.lua +++ b/plugins/mod_version.lua @@ -16,11 +16,11 @@ local query = st.stanza("query", {xmlns = "jabber:iq:version"}) :tag("name"):text("Prosody"):up() :tag("version"):text(prosody.version):up(); -if not module:get_option("hide_os_type") then +if not module:get_option_boolean("hide_os_type") then if os.getenv("WINDIR") then version = "Windows"; else - local os_version_command = module:get_option("os_version_command"); + local os_version_command = module:get_option_string("os_version_command"); local ok, pposix = pcall(require, "util.pposix"); if not os_version_command and (ok and pposix and pposix.uname) then version = pposix.uname().sysname; -- cgit v1.2.3 From 0655146d217181c4022989276762803fac3635d4 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Thu, 16 Mar 2017 20:53:08 +0100 Subject: mod_http_files: Use API for config options that are file paths --- plugins/mod_http_files.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/mod_http_files.lua b/plugins/mod_http_files.lua index 7735cfbb..e396df60 100644 --- a/plugins/mod_http_files.lua +++ b/plugins/mod_http_files.lua @@ -37,7 +37,7 @@ if not mime_map then }; module:shared("/*/http_files/mime").types = mime_map; - local mime_types, err = open(module:get_option_string("mime_types_file", "/etc/mime.types"),"r"); + local mime_types, err = open(module:get_option_path("mime_types_file", "/etc/mime.types", prosody.paths.config), "r"); if mime_types then local mime_data = mime_types:read("*a"); mime_types:close(); -- cgit v1.2.3 From e9634beff0b1b88b232722a926bb5ef00af89f1f Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Thu, 16 Mar 2017 21:01:45 +0100 Subject: mod_mam: Handle default_archive_policy option consistently --- plugins/mod_mam/mamprefs.lib.lua | 5 ++++- plugins/mod_mam/mod_mam.lua | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'plugins') diff --git a/plugins/mod_mam/mamprefs.lib.lua b/plugins/mod_mam/mamprefs.lib.lua index a561b9d5..72c08886 100644 --- a/plugins/mod_mam/mamprefs.lib.lua +++ b/plugins/mod_mam/mamprefs.lib.lua @@ -10,7 +10,10 @@ -- -- luacheck: ignore 122/prosody -local global_default_policy = module:get_option("default_archive_policy", true); +local global_default_policy = module:get_option_string("default_archive_policy", true); +if global_default_policy ~= "roster" then + global_default_policy = module:get_option_boolean("default_archive_policy", global_default_policy); +end do -- luacheck: ignore 211/prefs_format diff --git a/plugins/mod_mam/mod_mam.lua b/plugins/mod_mam/mod_mam.lua index 6e6d6383..7ea14502 100644 --- a/plugins/mod_mam/mod_mam.lua +++ b/plugins/mod_mam/mod_mam.lua @@ -35,7 +35,7 @@ local time_now = os.time; local m_min = math.min; local timestamp, timestamp_parse = require "util.datetime".datetime, require "util.datetime".parse; local default_max_items, max_max_items = 20, module:get_option_number("max_archive_query_results", 50); -local global_default_policy = module:get_option("default_archive_policy", true); +local global_default_policy = module:get_option_string("default_archive_policy", true); if global_default_policy ~= "roster" then global_default_policy = module:get_option_boolean("default_archive_policy", global_default_policy); end -- cgit v1.2.3 From 136d153105b435e22a3a0038372f0927117657f2 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Thu, 16 Mar 2017 21:02:40 +0100 Subject: mod_pubsub: Rely on type checking in module API --- plugins/mod_pubsub/mod_pubsub.lua | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'plugins') diff --git a/plugins/mod_pubsub/mod_pubsub.lua b/plugins/mod_pubsub/mod_pubsub.lua index 2b878ed8..18d85c52 100644 --- a/plugins/mod_pubsub/mod_pubsub.lua +++ b/plugins/mod_pubsub/mod_pubsub.lua @@ -9,8 +9,7 @@ local xmlns_pubsub_owner = "http://jabber.org/protocol/pubsub#owner"; local autocreate_on_publish = module:get_option_boolean("autocreate_on_publish", false); local autocreate_on_subscribe = module:get_option_boolean("autocreate_on_subscribe", false); -local pubsub_disco_name = module:get_option("name"); -if type(pubsub_disco_name) ~= "string" then pubsub_disco_name = "Prosody PubSub Service"; end +local pubsub_disco_name = module:get_option_string("name" "Prosody PubSub Service"); local expose_publisher = module:get_option_boolean("expose_publisher", false) local service; -- cgit v1.2.3