Mercurial > prosody-modules
diff mod_http_muc_log/mod_http_muc_log.lua @ 4676:a2cf3b69a3d6
mod_http_muc_log: Add way to list certain rooms in a specified order
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 12 Sep 2021 00:13:32 +0200 |
parents | 38f501dca618 |
children | 823370bc2e4c |
line wrap: on
line diff
--- a/mod_http_muc_log/mod_http_muc_log.lua Fri Sep 10 20:15:19 2021 +0200 +++ b/mod_http_muc_log/mod_http_muc_log.lua Sun Sep 12 00:13:32 2021 +0200 @@ -434,6 +434,13 @@ }); end +local room_weights = setmetatable(module:get_option_array(module.name.."_list_order", {}):reverse(), nil); +for i = #room_weights, 1, -1 do + local room_jid = room_weights[i]; + room_weights[i] = nil; + room_weights[room_jid] = i; +end + local function list_rooms(event) local request, response = event.request, event.response; local room_list, i = {}, 1; @@ -447,11 +454,13 @@ name = room:get_name() or localpart; lang = room.get_language and room:get_language(); description = room:get_description(); + priority = room_weights[ room.jid ] or 0; }, i + 1; end end table.sort(room_list, function (a, b) + if a.priority ~= b.priority then return a.priority > b.priority; end return a.jid < b.jid; end);