comparison mod_http_muc_log/mod_http_muc_log.lua @ 3596:6e529f53b3c3

mod_http_muc_log: Allow specifying the default view
author Kim Alvefur <zash@zash.se>
date Mon, 13 May 2019 00:52:35 +0200
parents 00a848ede42d
children da7ec4ed6ddf
comparison
equal deleted inserted replaced
3595:00a848ede42d 3596:6e529f53b3c3
94 end 94 end
95 95
96 return true; 96 return true;
97 end 97 end
98 98
99 -- Can be set to "latest"
100 local default_view = module:get_option_string(module.name .. "_default_view", nil);
101
99 module:hook("muc-disco#info", function (event) 102 module:hook("muc-disco#info", function (event)
100 local room = event.room; 103 local room = event.room;
101 if open_room(room) then 104 if open_room(room) then
102 table.insert(event.form, { name = "muc#roominfo_logs", type="text-single" }); 105 table.insert(event.form, { name = "muc#roominfo_logs", type="text-single" });
103 event.formdata["muc#roominfo_logs"] = get_absolute_link(jid_split(event.room.jid), nil); 106 event.formdata["muc#roominfo_logs"] = get_absolute_link(jid_split(event.room.jid), default_view);
104 end 107 end
105 end); 108 end);
106 109
107 local function sort_Y(a,b) return a.year > b.year end 110 local function sort_Y(a,b) return a.year > b.year end
108 local function sort_m(a,b) return a.n > b.n end 111 local function sort_m(a,b) return a.n > b.n end
369 local room_list, i = {}, 1; 372 local room_list, i = {}, 1;
370 for room in each_room() do 373 for room in each_room() do
371 if not (room.get_hidden or room.is_hidden)(room) then 374 if not (room.get_hidden or room.is_hidden)(room) then
372 room_list[i], i = { 375 room_list[i], i = {
373 jid = room.jid; 376 jid = room.jid;
374 href = get_link(jid_split(room.jid), nil); 377 href = get_link(jid_split(room.jid), default_view);
375 name = room:get_name(); 378 name = room:get_name();
376 description = room:get_description(); 379 description = room:get_description();
377 }, i + 1; 380 }, i + 1;
378 end 381 end
379 end 382 end