Mercurial > prosody-modules
comparison 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 |
comparison
equal
deleted
inserted
replaced
1831:004d3bfc05ea | 1832:48125f2c358b |
---|---|
82 local response = event.response; | 82 local response = event.response; |
83 | 83 |
84 local room = nodeprep(path:match("^(.*)/$")); | 84 local room = nodeprep(path:match("^(.*)/$")); |
85 if not room or not public_room(room) then return end | 85 if not room or not public_room(room) then return end |
86 | 86 |
87 local date_list = archive.dates and archive:dates(room); | |
87 local dates = mt.new(); | 88 local dates = mt.new(); |
88 module:log("debug", "Find all dates with messages"); | 89 if date_list then |
89 local next_day; | 90 for _, date in ipairs(date_list) do |
90 repeat | 91 local when = datetime.parse(date.."T00:00:00Z"); |
91 local when = find_once(room, { start = next_day; with = "message<groupchat"; }, 3); | 92 local t = os_date("!*t", when); |
92 if not when then break; end | 93 dates:set(t.year, t.month, t.day, when); |
93 local t = os_date("!*t", when); | 94 end |
94 dates:set(t.year, t.month, t.day, when ); | 95 else |
95 next_day = when + (86400 - (when % 86400)); | 96 module:log("debug", "Find all dates with messages"); |
96 until not next_day; | 97 local next_day; |
98 repeat | |
99 local when = find_once(room, { start = next_day; with = "message<groupchat"; }, 3); | |
100 if not when then break; end | |
101 local t = os_date("!*t", when); | |
102 dates:set(t.year, t.month, t.day, when ); | |
103 next_day = when + (86400 - (when % 86400)); | |
104 until not next_day; | |
105 end | |
97 | 106 |
98 local years = {}; | 107 local years = {}; |
99 | 108 |
100 for current_year, months_t in pairs(dates.data) do | 109 for current_year, months_t in pairs(dates.data) do |
101 local t = { year = current_year, month = 1, day = 1 }; | 110 local t = { year = current_year, month = 1, day = 1 }; |