Mercurial > prosody-modules
comparison mod_http_muc_log/mod_http_muc_log.lua @ 2839:7738d7158dd0
mod_http_muc_log: Return a 404 page if there are no messages to derive a time span from
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 18 Nov 2017 20:44:47 +0100 |
parents | 5125e187768f |
children | 683a2f25223d |
comparison
equal
deleted
inserted
replaced
2838:5125e187768f | 2839:7738d7158dd0 |
---|---|
101 end | 101 end |
102 elseif lazy then | 102 elseif lazy then |
103 -- Lazy with many false positives | 103 -- Lazy with many false positives |
104 local first_day = find_once(room, nil, 3); | 104 local first_day = find_once(room, nil, 3); |
105 local last_day = find_once(room, { reverse = true }, 3); | 105 local last_day = find_once(room, { reverse = true }, 3); |
106 first_day = date_floor(first_day); | 106 if first_day and last_day then |
107 last_day = date_floor(last_day); | 107 first_day = date_floor(first_day); |
108 for when = first_day, last_day, 86400 do | 108 last_day = date_floor(last_day); |
109 local t = os_date("!*t", when); | 109 for when = first_day, last_day, 86400 do |
110 dates:set(t.year, t.month, t.day, when); | 110 local t = os_date("!*t", when); |
111 dates:set(t.year, t.month, t.day, when); | |
112 end | |
113 else | |
114 return; -- 404 | |
111 end | 115 end |
112 else | 116 else |
113 -- Collect date the hard way | 117 -- Collect date the hard way |
114 module:log("debug", "Find all dates with messages"); | 118 module:log("debug", "Find all dates with messages"); |
115 local next_day; | 119 local next_day; |