From 5c7a04bc7b0b4fac73fa2259715ba030aa792ff4 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Mon, 28 Nov 2016 07:30:39 +0100 Subject: mod_storage_sql: Use is_stanza() from util.stanza --- plugins/mod_storage_sql.lua | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'plugins') diff --git a/plugins/mod_storage_sql.lua b/plugins/mod_storage_sql.lua index 4f46b3f6..b7ade340 100644 --- a/plugins/mod_storage_sql.lua +++ b/plugins/mod_storage_sql.lua @@ -7,10 +7,8 @@ local xml_parse = require "util.xml".parse; local uuid = require "util.uuid"; local resolve_relative_path = require "util.paths".resolve_relative_path; -local stanza_mt = require"util.stanza".stanza_mt; -local getmetatable = getmetatable; +local is_stanza = require"util.stanza".is_stanza; local t_concat = table.concat; -local function is_stanza(x) return getmetatable(x) == stanza_mt; end local noop = function() end local unpack = unpack -- cgit v1.2.3 From 42f67b2a729db0b48129109ef9cd41f0fd476ec1 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Tue, 29 Nov 2016 08:20:42 +0100 Subject: mod_storage_sql: Create a new table to hold normalized database parameters (fixes #636) --- plugins/mod_storage_sql.lua | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'plugins') diff --git a/plugins/mod_storage_sql.lua b/plugins/mod_storage_sql.lua index b7ade340..fa241ed9 100644 --- a/plugins/mod_storage_sql.lua +++ b/plugins/mod_storage_sql.lua @@ -433,14 +433,22 @@ local function upgrade_table(params, apply_changes) return changes; end -local function normalize_params(params) - if params.driver == "SQLite3" then - if params.database ~= ":memory:" then - params.database = resolve_relative_path(prosody.paths.data or ".", params.database or "prosody.sqlite"); - end +local function normalize_database(driver, database) + if driver == "SQLite3" and database ~= ":memory:" then + return resolve_relative_path(prosody.paths.data or ".", database or "prosody.sqlite"); end - assert(params.driver and params.database, "Configuration error: Both the SQL driver and the database need to be specified"); - return params; + return database; +end + +local function normalize_params(params) + return { + driver = assert(params.driver, "Configuration error: Both the SQL driver and the database need to be specified"); + database = assert(normalize_database(params.driver, params.database), "Configuration error: Both the SQL driver and the database need to be specified"); + username = params.username; + password = params.password; + host = params.host; + params.port; + }; end function module.load() -- cgit v1.2.3 From 3d31b0f2ebd4b806ea1d084bf44b9ee2ac594655 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Thu, 1 Dec 2016 03:22:42 +0100 Subject: mod_storage_sql: Include missing parameter table key 'port' --- plugins/mod_storage_sql.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/mod_storage_sql.lua b/plugins/mod_storage_sql.lua index fa241ed9..aef7ff8b 100644 --- a/plugins/mod_storage_sql.lua +++ b/plugins/mod_storage_sql.lua @@ -447,7 +447,7 @@ local function normalize_params(params) username = params.username; password = params.password; host = params.host; - params.port; + port = params.port; }; end -- cgit v1.2.3 From 854e22b394fd523c783e79a2a03a4dab28e7e5d6 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Thu, 1 Dec 2016 06:47:03 +0100 Subject: mod_register: Record the time of registration in the account details store --- plugins/mod_register.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'plugins') diff --git a/plugins/mod_register.lua b/plugins/mod_register.lua index eaa0614d..c376117f 100644 --- a/plugins/mod_register.lua +++ b/plugins/mod_register.lua @@ -257,6 +257,7 @@ module:hook("stanza/iq/jabber:iq:register:query", function(event) -- TODO unable to write file, file may be locked, etc, what's the correct error? local error_reply = st.error_reply(stanza, "wait", "internal-server-error", "Failed to write data to disk."); if usermanager_create_user(username, password, host) then + data.registered = os.time(); if next(data) and not account_details:set(username, data) then log("debug", "Could not store extra details"); usermanager_delete_user(username, host); -- cgit v1.2.3 From b4b0a1a7f20ac379d6c4fcd64e5c6331fb47620d Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Thu, 1 Dec 2016 10:02:01 +0100 Subject: mod_storage_sql: Don't say 'Unknown command' if no command was given (fixes attempt to concatenate nil) --- plugins/mod_storage_sql.lua | 2 ++ 1 file changed, 2 insertions(+) (limited to 'plugins') diff --git a/plugins/mod_storage_sql.lua b/plugins/mod_storage_sql.lua index aef7ff8b..1872ea34 100644 --- a/plugins/mod_storage_sql.lua +++ b/plugins/mod_storage_sql.lua @@ -504,6 +504,8 @@ function module.command(arg) upgrade_table(params, true); end print("All done!"); + elseif command then + print("Unknown command: "..command); else print("Unknown command: "..command); end -- cgit v1.2.3 From 547a7061bc8fd3c4f5f490bb7f54fc26558f6e26 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Thu, 1 Dec 2016 10:02:26 +0100 Subject: mod_storage_sql: List available commands if no commands given (currenly only one available) --- plugins/mod_storage_sql.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/mod_storage_sql.lua b/plugins/mod_storage_sql.lua index 1872ea34..67a441b7 100644 --- a/plugins/mod_storage_sql.lua +++ b/plugins/mod_storage_sql.lua @@ -507,6 +507,7 @@ function module.command(arg) elseif command then print("Unknown command: "..command); else - print("Unknown command: "..command); + print("Available commands:"); + print("","upgrade - Perform database upgrade"); end end -- cgit v1.2.3 From b505c4dd28533f117a2085a020426111411e6d88 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Thu, 1 Dec 2016 10:02:57 +0100 Subject: mod_storage_sql: Normalize parameters for upgrade command --- plugins/mod_storage_sql.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/mod_storage_sql.lua b/plugins/mod_storage_sql.lua index 67a441b7..819846bb 100644 --- a/plugins/mod_storage_sql.lua +++ b/plugins/mod_storage_sql.lua @@ -484,7 +484,7 @@ function module.command(arg) -- We need to find every unique dburi in the config local uris = {}; for host in pairs(prosody.hosts) do - local params = config.get(host, "sql") or default_params; + local params = normalize_params(config.get(host, "sql") or default_params); uris[sql.db2uri(params)] = params; end print("We will check and upgrade the following databases:\n"); -- cgit v1.2.3