comparison mod_http_muc_log/mod_http_muc_log.lua @ 3582:444e2306c99a

mod_http_muc_log: Add option to show OOB images
author Kim Alvefur <zash@zash.se>
date Sun, 05 May 2019 14:06:50 +0200
parents ea63dc0cc824
children a36412d4fafd
comparison
equal deleted inserted replaced
3581:dbc67120097f 3582:444e2306c99a
26 local function get_room(name) 26 local function get_room(name)
27 local jid = name .. '@' .. module.host; 27 local jid = name .. '@' .. module.host;
28 return get_room_from_jid(jid); 28 return get_room_from_jid(jid);
29 end 29 end
30 30
31 local use_oob = module:get_option_boolean(module.name .. "_show_images", false);
31 module:depends"http"; 32 module:depends"http";
32 33
33 local template; 34 local template;
34 do 35 do
35 local template_filename = module:get_option_string(module.name .. "_template", module.name .. ".html"); 36 local template_filename = module:get_option_string(module.name .. "_template", module.name .. ".html");
266 verb, body = body:sub(5), nil; 267 verb, body = body:sub(5), nil;
267 elseif item.name == "presence" then 268 elseif item.name == "presence" then
268 -- TODO Distinguish between join and presence update 269 -- TODO Distinguish between join and presence update
269 verb = item.attr.type == "unavailable" and "has left" or "has joined"; 270 verb = item.attr.type == "unavailable" and "has left" or "has joined";
270 end 271 end
271 if body or verb then 272 local oob = use_oob and item:get_child("x", "jabber:x:oob");
272 logs[i], i = { 273 if body or verb or oob then
274 local line = {
273 key = key; 275 key = key;
274 datetime = datetime.datetime(when); 276 datetime = datetime.datetime(when);
275 time = datetime.time(when); 277 time = datetime.time(when);
276 verb = verb; 278 verb = verb;
277 body = body; 279 body = body;
278 nick = select(3, jid_split(item.attr.from)); 280 nick = select(3, jid_split(item.attr.from));
279 st_name = item.name; 281 st_name = item.name;
280 st_type = item.attr.type; 282 st_type = item.attr.type;
281 }, i + 1; 283 };
284 if oob then
285 line.oob = {
286 url = oob:get_child_text("url");
287 desc = oob:get_child_text("desc");
288 }
289 end
290 logs[i], i = line, i + 1;
282 end 291 end
283 first = first or key; 292 first = first or key;
284 last = key; 293 last = key;
285 end 294 end
286 if i == 1 and not lazy then return end -- No items 295 if i == 1 and not lazy then return end -- No items