# HG changeset patch # User Kim Alvefur # Date 1631398412 -7200 # Node ID a2cf3b69a3d669975f47a480da8f1bce56225cb1 # Parent c9397cd5cfe668af192fff61de4db31fc69165a8 mod_http_muc_log: Add way to list certain rooms in a specified order diff -r c9397cd5cfe6 -r a2cf3b69a3d6 mod_http_muc_log/README.markdown --- a/mod_http_muc_log/README.markdown Fri Sep 10 20:15:19 2021 +0200 +++ b/mod_http_muc_log/README.markdown Sun Sep 12 00:13:32 2021 +0200 @@ -87,6 +87,18 @@ http_muc_log_lazy_calendar = false ``` +## Pinned chatrooms + +The room list page is normally sorted by address. To override this, or +pin certain rooms to the top: + +``` lua +http_muc_log_list_order = { + "general@channels.example.com", + "support@channels.example.com", +} +``` + Compatibility ============= diff -r c9397cd5cfe6 -r a2cf3b69a3d6 mod_http_muc_log/mod_http_muc_log.lua --- 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);