Mercurial > prosody-modules
diff mod_http_muc_log/mod_http_muc_log.lua @ 1832:48125f2c358b
mod_http_muc_log: If archive driver provides the dates method, use it
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 07 Sep 2015 16:27:26 +0200 |
parents | 3b839db88412 |
children | c5ee48e27d01 |
line wrap: on
line diff
--- a/mod_http_muc_log/mod_http_muc_log.lua Mon Sep 07 16:26:52 2015 +0200 +++ b/mod_http_muc_log/mod_http_muc_log.lua Mon Sep 07 16:27:26 2015 +0200 @@ -84,16 +84,25 @@ local room = nodeprep(path:match("^(.*)/$")); if not room or not public_room(room) then return end + local date_list = archive.dates and archive:dates(room); local dates = mt.new(); - module:log("debug", "Find all dates with messages"); - local next_day; - repeat - local when = find_once(room, { start = next_day; with = "message<groupchat"; }, 3); - if not when then break; end - local t = os_date("!*t", when); - dates:set(t.year, t.month, t.day, when ); - next_day = when + (86400 - (when % 86400)); - until not next_day; + if date_list then + for _, date in ipairs(date_list) do + local when = datetime.parse(date.."T00:00:00Z"); + local t = os_date("!*t", when); + dates:set(t.year, t.month, t.day, when); + end + else + module:log("debug", "Find all dates with messages"); + local next_day; + repeat + local when = find_once(room, { start = next_day; with = "message<groupchat"; }, 3); + if not when then break; end + local t = os_date("!*t", when); + dates:set(t.year, t.month, t.day, when ); + next_day = when + (86400 - (when % 86400)); + until not next_day; + end local years = {};