aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2016-12-02 11:13:05 +0100
committerKim Alvefur <zash@zash.se>2016-12-02 11:13:05 +0100
commit2a9484a488a5878e27b5d749b5bbb0d54f497e86 (patch)
treeb8d5008111c5708e9ee236f6139e5100ccd683d2 /plugins
parentd83f4d63b00b4cf561ad1c81f31f43b560bd7bd1 (diff)
parent738528509c19ea443b4066e49b7a93fd2317b0ee (diff)
downloadprosody-2a9484a488a5878e27b5d749b5bbb0d54f497e86.tar.gz
prosody-2a9484a488a5878e27b5d749b5bbb0d54f497e86.zip
Merge 0.10->trunk
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mod_register.lua1
-rw-r--r--plugins/mod_storage_sql.lua33
2 files changed, 22 insertions, 12 deletions
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);
diff --git a/plugins/mod_storage_sql.lua b/plugins/mod_storage_sql.lua
index 60870a01..50d9cd0f 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
@@ -435,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;
+ port = params.port;
+ };
end
function module.load()
@@ -478,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");
@@ -498,7 +504,10 @@ function module.command(arg)
upgrade_table(params, true);
end
print("All done!");
- else
+ elseif command then
print("Unknown command: "..command);
+ else
+ print("Available commands:");
+ print("","upgrade - Perform database upgrade");
end
end