Mercurial > prosody-modules
comparison mod_http_muc_log/mod_http_muc_log.lua @ 3591:3f8383c5a045
mod_http_muc_log: Fix Y10k bug
Mostly in preparation for the next commit
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 13 May 2019 00:20:19 +0200 |
parents | a36412d4fafd |
children | 61a9c087730a |
comparison
equal
deleted
inserted
replaced
3590:d8cc8b71a199 | 3591:3f8383c5a045 |
---|---|
228 | 228 |
229 -- Produce the chat log view | 229 -- Produce the chat log view |
230 local function logs_page(event, path) | 230 local function logs_page(event, path) |
231 local request, response = event.request, event.response; | 231 local request, response = event.request, event.response; |
232 | 232 |
233 -- FIXME In the year, 105105, if MUC is still alive, | 233 local room, date = path:match("^([^/]+)/([^/]*)/?$"); |
234 -- if Prosody can survive... Enjoy this Y10k bug | |
235 local room, date = path:match("^(.-)/(%d%d%d%d%-%d%d%-%d%d)/?$"); | |
236 room = nodeprep(room); | 234 room = nodeprep(room); |
237 if not room then | 235 if not room then |
236 return 400; | |
237 elseif date == "" then | |
238 return years_page(event, path); | 238 return years_page(event, path); |
239 end | 239 end |
240 local is_open = open_room(room); | 240 local is_open = open_room(room); |
241 if is_open == nil then | 241 if is_open == nil then |
242 return -- implicit 404 | 242 return -- implicit 404 |
243 elseif is_open == false then | 243 elseif is_open == false then |
244 return 403; | 244 return 403; |
245 end | 245 end |
246 local day_start = datetime.parse(date.."T00:00:00Z"); | 246 local day_start = datetime.parse(date.."T00:00:00Z"); |
247 if not day_start then | |
248 module:log("debug", "Invalid date format: %q", date); | |
249 return 400; | |
250 end | |
247 | 251 |
248 local logs, i = {}, 1; | 252 local logs, i = {}, 1; |
249 local iter, err = archive:find(room, { | 253 local iter, err = archive:find(room, { |
250 ["start"] = day_start; | 254 ["start"] = day_start; |
251 ["end"] = day_start + 86399; | 255 ["end"] = day_start + 86399; |