# HG changeset patch # User Kim Alvefur # Date 1610827498 -3600 # Node ID 1730383067508fcfce38c0d38090856c03b5d259 # Parent 65fb0d7a2312410be7a274080a5d83bf933dd4e8 plugins: Use get_option_enum where appropriate diff -r 65fb0d7a2312 -r 173038306750 plugins/mod_auth_internal_hashed.lua --- a/plugins/mod_auth_internal_hashed.lua Sat Jan 16 20:40:14 2021 +0100 +++ b/plugins/mod_auth_internal_hashed.lua Sat Jan 16 21:04:58 2021 +0100 @@ -22,7 +22,7 @@ local accounts = module:open_store("accounts"); -local hash_name = module:get_option_string("password_hash", "SHA-1"); +local hash_name = module:get_option_enum("password_hash", "SHA-1", "SHA-256"); local get_auth_db = assert(scram_hashers[hash_name], "SCRAM-"..hash_name.." not supported by SASL library"); local scram_name = "scram_"..hash_name:gsub("%-","_"):lower(); diff -r 65fb0d7a2312 -r 173038306750 plugins/mod_component.lua --- a/plugins/mod_component.lua Sat Jan 16 20:40:14 2021 +0100 +++ b/plugins/mod_component.lua Sat Jan 16 21:04:58 2021 +0100 @@ -85,7 +85,7 @@ end if env.connected then - local policy = module:get_option_string("component_conflict_resolve", "kick_new"); + local policy = module:get_option_enum("component_conflict_resolve", "kick_new", "kick_old"); if policy == "kick_old" then env.session:close{ condition = "conflict", text = "Replaced by a new connection" }; else -- kick_new diff -r 65fb0d7a2312 -r 173038306750 plugins/mod_mam/mamprefs.lib.lua --- a/plugins/mod_mam/mamprefs.lib.lua Sat Jan 16 20:40:14 2021 +0100 +++ b/plugins/mod_mam/mamprefs.lib.lua Sat Jan 16 21:04:58 2021 +0100 @@ -10,11 +10,14 @@ -- -- luacheck: ignore 122/prosody -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); +local global_default_policy = module:get_option_enum("default_archive_policy", "always", "roster", "never", true, false); +local smart_enable = module:get_option_boolean("mam_smart_enable", false); + +if global_default_policy == "always" then + global_default_policy = true; +elseif global_default_policy == "never" then + global_default_policy = false; end -local smart_enable = module:get_option_boolean("mam_smart_enable", false); do -- luacheck: ignore 211/prefs_format diff -r 65fb0d7a2312 -r 173038306750 plugins/mod_pubsub/mod_pubsub.lua --- a/plugins/mod_pubsub/mod_pubsub.lua Sat Jan 16 20:40:14 2021 +0100 +++ b/plugins/mod_pubsub/mod_pubsub.lua Sat Jan 16 21:04:58 2021 +0100 @@ -179,7 +179,7 @@ end end); -local admin_aff = module:get_option_string("default_admin_affiliation", "owner"); +local admin_aff = module:get_option_enum("default_admin_affiliation", "owner", "publisher", "member", "outcast", "none"); module:default_permission("prosody:admin", ":service-admin"); local function get_affiliation(jid) local bare_jid = jid_bare(jid); diff -r 65fb0d7a2312 -r 173038306750 plugins/mod_watchregistrations.lua --- a/plugins/mod_watchregistrations.lua Sat Jan 16 20:40:14 2021 +0100 +++ b/plugins/mod_watchregistrations.lua Sat Jan 16 21:04:58 2021 +0100 @@ -13,7 +13,7 @@ local registration_watchers = module:get_option_set("registration_watchers", module:get_option("admins", {})) / jid_prep; local registration_from = module:get_option_string("registration_from", host); local registration_notification = module:get_option_string("registration_notification", "User $username just registered on $host from $ip"); -local msg_type = module:get_option_string("registration_notification_type", "chat"); +local msg_type = module:get_option_enum("registration_notification_type", "chat", "normal", "headline"); local st = require "prosody.util.stanza";