From 0652f919b8d9a7dd998cbdbb5eac45697f5141b7 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Tue, 17 Oct 2017 12:42:20 +0200 Subject: mod_mam: Load archiving preferes for offline users (fixes #1024) --- plugins/mod_mam/mamprefs.lib.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plugins/mod_mam/mamprefs.lib.lua b/plugins/mod_mam/mamprefs.lib.lua index 72c08886..1e05b9d1 100644 --- a/plugins/mod_mam/mamprefs.lib.lua +++ b/plugins/mod_mam/mamprefs.lib.lua @@ -33,9 +33,11 @@ local prefs = module:open_store(archive_store .. "_prefs"); local function get_prefs(user) local user_sessions = sessions[user]; local user_prefs = user_sessions and user_sessions.archive_prefs - if not user_prefs and user_sessions then + if not user_prefs then user_prefs = prefs:get(user); - user_sessions.archive_prefs = user_prefs; + if user_sessions then + user_sessions.archive_prefs = user_prefs; + end end return user_prefs or { [false] = global_default_policy }; end -- cgit v1.2.3 From 67bef1f73cbad7906ffcc6562fa7dfc90b60d8fa Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Thu, 26 Oct 2017 22:22:14 +0200 Subject: mod_carbons: Synthesize a 'to' attribute for carbons of stanzas to "self" (fixes #956) --- plugins/mod_carbons.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/mod_carbons.lua b/plugins/mod_carbons.lua index cb7d9233..1dcd4a07 100644 --- a/plugins/mod_carbons.lua +++ b/plugins/mod_carbons.lua @@ -76,6 +76,9 @@ local function message_handler(event, c2s) -- Create the carbon copy and wrap it as per the Stanza Forwarding XEP local copy = st.clone(stanza); + if c2s and not orig_to then + stanza.attr.to = bare_from; + end copy.attr.xmlns = "jabber:client"; local carbon = st.message{ from = bare_jid, type = orig_type, } :tag(c2s and "sent" or "received", { xmlns = xmlns_carbons }) -- cgit v1.2.3 From 7160daef7907b588168d46ebf6d306cc90d8b1b7 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Thu, 26 Oct 2017 22:30:52 +0200 Subject: loggingmanager: Make timestamps enabled by default in file sink (fixes #1004) --- core/loggingmanager.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/loggingmanager.lua b/core/loggingmanager.lua index 6dc1c1d1..004f4c3b 100644 --- a/core/loggingmanager.lua +++ b/core/loggingmanager.lua @@ -178,7 +178,7 @@ local function log_to_file(sink_config, logfile) local timestamps = sink_config.timestamps; - if timestamps == true then + if timestamps == true or timestamps == nil then timestamps = default_timestamp; -- Default format elseif timestamps then timestamps = timestamps .. " "; -- cgit v1.2.3 From ccc4e2a83f81a07ef522a271738a34c75c2a4752 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Tue, 19 Sep 2017 19:17:07 +0200 Subject: rostermanager: Simplify logging. --- core/rostermanager.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/rostermanager.lua b/core/rostermanager.lua index c94482c4..04f97f22 100644 --- a/core/rostermanager.lua +++ b/core/rostermanager.lua @@ -104,9 +104,9 @@ local function load_roster(username, host) if user then roster = user.roster; if roster then return roster; end - log("debug", "load_roster: loading for new user: %s@%s", username, host); + log("debug", "load_roster: loading for new user: %s", jid); else -- Attempt to load roster for non-loaded user - log("debug", "load_roster: loading for offline user: %s@%s", username, host); + log("debug", "load_roster: loading for offline user: %s", jid); end local roster_store = storagemanager.open(host, "roster", "keyval"); local data, err = roster_store:get(username); -- cgit v1.2.3 From e2a3d500049d4b7616388bf6f6cf94a51283a459 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Tue, 19 Sep 2017 19:17:23 +0200 Subject: rostermanager: Remove self-contact entry (fixes #933) --- core/rostermanager.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/rostermanager.lua b/core/rostermanager.lua index 04f97f22..ac5104c3 100644 --- a/core/rostermanager.lua +++ b/core/rostermanager.lua @@ -115,7 +115,8 @@ local function load_roster(username, host) roster_metadata(roster, err); if roster[jid] then roster[jid] = nil; - log("warn", "roster for %s has a self-contact", jid); + log("warn", "roster for %s had a self-contact, removing", jid); + roster_store:set(username, roster); end if not err then hosts[host].events.fire_event("roster-load", { username = username, host = host, roster = roster }); -- cgit v1.2.3 From 8bdde46dfd3b858f723219f8627951b90ff82a05 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 29 Oct 2017 00:05:26 +0200 Subject: rostermanager: Capitalize log message --- core/rostermanager.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/rostermanager.lua b/core/rostermanager.lua index ac5104c3..32de3a54 100644 --- a/core/rostermanager.lua +++ b/core/rostermanager.lua @@ -115,7 +115,7 @@ local function load_roster(username, host) roster_metadata(roster, err); if roster[jid] then roster[jid] = nil; - log("warn", "roster for %s had a self-contact, removing", jid); + log("warn", "Roster for %s had a self-contact, removing", jid); roster_store:set(username, roster); end if not err then -- cgit v1.2.3 From 1925151837c00dd072dc1524853e07a7eebb382b Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 29 Oct 2017 00:06:26 +0200 Subject: rostermanager: Demote warning to debug message --- core/rostermanager.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/rostermanager.lua b/core/rostermanager.lua index 32de3a54..6acc1003 100644 --- a/core/rostermanager.lua +++ b/core/rostermanager.lua @@ -115,7 +115,7 @@ local function load_roster(username, host) roster_metadata(roster, err); if roster[jid] then roster[jid] = nil; - log("warn", "Roster for %s had a self-contact, removing", jid); + log("debug", "Roster for %s had a self-contact, removing", jid); roster_store:set(username, roster); end if not err then -- cgit v1.2.3 From 1ba31ce34d74feeb3de0db2c3093fb7f99a5c3b0 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 29 Oct 2017 00:07:18 +0200 Subject: rostermanager: Use internal method for storing removal of self-contact --- core/rostermanager.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/rostermanager.lua b/core/rostermanager.lua index 6acc1003..dda69e7c 100644 --- a/core/rostermanager.lua +++ b/core/rostermanager.lua @@ -116,7 +116,7 @@ local function load_roster(username, host) if roster[jid] then roster[jid] = nil; log("debug", "Roster for %s had a self-contact, removing", jid); - roster_store:set(username, roster); + save_roster(username, host, roster, jid); end if not err then hosts[host].events.fire_event("roster-load", { username = username, host = host, roster = roster }); -- cgit v1.2.3 From b04b0835bc48d7578eb9a679ce5d23e2b4d9e192 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 29 Oct 2017 00:07:45 +0200 Subject: rostermanager: Log warning if removal self-contact failed --- core/rostermanager.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/rostermanager.lua b/core/rostermanager.lua index dda69e7c..f6a44028 100644 --- a/core/rostermanager.lua +++ b/core/rostermanager.lua @@ -116,7 +116,9 @@ local function load_roster(username, host) if roster[jid] then roster[jid] = nil; log("debug", "Roster for %s had a self-contact, removing", jid); - save_roster(username, host, roster, jid); + if not save_roster(username, host, roster, jid) then + log("warn", "Could not remove self-contact from roster for %s", jid); + end end if not err then hosts[host].events.fire_event("roster-load", { username = username, host = host, roster = roster }); -- cgit v1.2.3 From 8ea1a04ab9626b90c22250c4189a540ea0c58c9e Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Fri, 27 Oct 2017 14:08:28 +0200 Subject: net.http.server: Include response object in most http-error events --- net/http/server.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/net/http/server.lua b/net/http/server.lua index 8aa28f5c..877c7f17 100644 --- a/net/http/server.lua +++ b/net/http/server.lua @@ -229,7 +229,7 @@ function handle_request(conn, request, finish_cb) if err then response.status_code = err_code; - response:send(events.fire_event("http-error", { code = err_code, message = err })); + response:send(events.fire_event("http-error", { code = err_code, message = err, response = response })); return; end @@ -244,7 +244,8 @@ function handle_request(conn, request, finish_cb) if result_type == "number" then response.status_code = result; if result >= 400 then - body = events.fire_event("http-error", { code = result }); + payload.code = result; + body = events.fire_event("http-error", payload); end elseif result_type == "string" then body = result; @@ -266,7 +267,8 @@ function handle_request(conn, request, finish_cb) -- if handler not called, return 404 response.status_code = 404; - response:send(events.fire_event("http-error", { code = 404 })); + payload.code = 404; + response:send(events.fire_event("http-error", payload)); end local function prepare_header(response) local status_line = "HTTP/"..response.request.httpversion.." "..(response.status or codes[response.status_code]); -- cgit v1.2.3 From a624cae351afc239ee1ebe08d29bfbadce8b0a81 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Fri, 27 Oct 2017 13:28:34 +0200 Subject: mod_http_errors: Set Content-Type header to HTML (fixes #1030) --- plugins/mod_http_errors.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/mod_http_errors.lua b/plugins/mod_http_errors.lua index 17d357e5..d8646268 100644 --- a/plugins/mod_http_errors.lua +++ b/plugins/mod_http_errors.lua @@ -72,5 +72,8 @@ local function get_page(code, extra) end module:hook_object_event(server, "http-error", function (event) + if event.response then + event.response.headers.content_type = "text/html; charset=utf-8"; + end return get_page(event.code, (show_private and event.private_message) or event.message); end); -- cgit v1.2.3 From b8d1d533fdf9b9e0d348a4f8d4204e6a1f87a5bd Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Fri, 27 Oct 2017 13:27:35 +0200 Subject: mod_http_errors: Use util.interpolation to render HTML template --- plugins/mod_http_errors.lua | 61 +++++++++++++++++++++------------------------ 1 file changed, 28 insertions(+), 33 deletions(-) diff --git a/plugins/mod_http_errors.lua b/plugins/mod_http_errors.lua index d8646268..13473219 100644 --- a/plugins/mod_http_errors.lua +++ b/plugins/mod_http_errors.lua @@ -2,6 +2,8 @@ module:set_global(); local server = require "net.http.server"; local codes = require "net.http.codes"; +local xml_escape = require "util.stanza".xml_escape; +local render = require "util.interpolation".new("%b{}", xml_escape); local show_private = module:get_option_boolean("http_errors_detailed", false); local always_serve = module:get_option_boolean("http_errors_always_show", true); @@ -21,53 +23,46 @@ local html = [[ - - + +{title} + -

$title

-

$message

-

$extra

+

{title}

+

{message}

+

{extra?}

]]; -html = html:gsub("%s%s+", ""); - -local entities = { - ["<"] = "<", [">"] = ">", ["&"] = "&", - ["'"] = "'", ["\""] = """, ["\n"] = "
", -}; - -local function tohtml(plain) - return (plain:gsub("[<>&'\"\n]", entities)); - -end local function get_page(code, extra) local message = messages[code]; if always_serve or message then message = message or default_message; - return (html:gsub("$(%a+)", { + return render(html, { title = rawget(codes, code) or ("Code "..tostring(code)); message = message[1]:gsub("%%", function () return message[math.random(2, math.max(#message,2))]; end); - extra = tohtml(extra or ""); - })); + extra = extra; + }); end end -- cgit v1.2.3 From 63e10c1c271e70eafc4257a54b07178488e33de1 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Mon, 23 Oct 2017 12:46:11 +0200 Subject: man prosodyctl: Highlight subcommands --- man/prosodyctl.man | 14 +++++++------- man/prosodyctl.markdown | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/man/prosodyctl.man b/man/prosodyctl.man index 3ea42cdd..0d3cf5d6 100644 --- a/man/prosodyctl.man +++ b/man/prosodyctl.man @@ -93,33 +93,33 @@ and private keys for use with Prosody. Commands are of the form \f[C]prosodyctl\ cert\ subcommand\f[]. Commands take a list of hosts to be included in the certificate. .TP -.B request hosts +.B \f[C]request\ hosts\f[] Create a certificate request (CSR) file for submission to a certificate authority. Multiple hosts can be given, sub\-domains are automatically included. .RS .RE .TP -.B generate hosts +.B \f[C]generate\ hosts\f[] Generate a self\-signed certificate. .RS .RE .TP -.B key host [size] +.B \f[C]key\ host\ [size]\f[] Generate a private key of \[aq]size\[aq] bits (defaults to 2048). Invoked automatically by \[aq]request\[aq] and \[aq]generate\[aq] if needed. .RS .RE .TP -.B config hosts +.B \f[C]config\ hosts\f[] Produce a config file for the list of hosts. Invoked automatically by \[aq]request\[aq] and \[aq]generate\[aq] if needed. .RS .RE .TP -.B import hosts paths +.B \f[C]import\ hosts\ paths\f[] Copy certificates for hosts into the certificate path and reload prosody. .RS @@ -129,13 +129,13 @@ prosody. prosodyctl can also show some information about the environment, dependencies and such to aid in debugging. .TP -.B about +.B \f[C]about\f[] Shows environment, various paths used by Prosody and installed dependencies. .RS .RE .TP -.B check [what] +.B \f[C]check\ [what]\f[] Performs various sanity checks on the configuration, DNS setup and configured TLS certificates. \f[C]what\f[] can be one of \f[C]config\f[], \f[C]dns\f[] and diff --git a/man/prosodyctl.markdown b/man/prosodyctl.markdown index 9cc15985..121547fd 100644 --- a/man/prosodyctl.markdown +++ b/man/prosodyctl.markdown @@ -88,23 +88,23 @@ private keys for use with Prosody. Commands are of the form `prosodyctl cert subcommand`. Commands take a list of hosts to be included in the certificate. -request hosts +`request hosts` : Create a certificate request (CSR) file for submission to a certificate authority. Multiple hosts can be given, sub-domains are automatically included. -generate hosts +`generate hosts` : Generate a self-signed certificate. -key host \[size\] +`key host [size]` : Generate a private key of 'size' bits (defaults to 2048). Invoked automatically by 'request' and 'generate' if needed. -config hosts +`config hosts` : Produce a config file for the list of hosts. Invoked automatically by 'request' and 'generate' if needed. -import hosts paths +`import hosts paths` : Copy certificates for hosts into the certificate path and reload prosody. @@ -114,11 +114,11 @@ Debugging prosodyctl can also show some information about the environment, dependencies and such to aid in debugging. -about +`about` : Shows environment, various paths used by Prosody and installed dependencies. -check \[what\] +`check [what]` : Performs various sanity checks on the configuration, DNS setup and configured TLS certificates. `what` can be one of `config`, `dns` and `certs` to run only that check. -- cgit v1.2.3