mod_http_muc_log: Provide a redirect to 'latest' day with logs (fixes #1360)
authorKim Alvefur <zash@zash.se>
Mon, 13 May 2019 00:23:04 +0200
changeset 3596 61a9c087730a
parent 3595 3f8383c5a045
child 3597 0b670831ace3
mod_http_muc_log: Provide a redirect to 'latest' day with logs (fixes #1360)
mod_http_muc_log/mod_http_muc_log.lua
--- a/mod_http_muc_log/mod_http_muc_log.lua	Mon May 13 00:20:19 2019 +0200
+++ b/mod_http_muc_log/mod_http_muc_log.lua	Mon May 13 00:23:04 2019 +0200
@@ -243,6 +243,11 @@
 	elseif is_open == false then
 		return 403;
 	end
+	if date == "latest" then
+		local last_day = find_once(room, { reverse = true }, 3);
+		response.headers.location = datetime.date(last_day);
+		return 303;
+	end
 	local day_start = datetime.parse(date.."T00:00:00Z");
 	if not day_start then
 		module:log("debug", "Invalid date format: %q", date);