mod_http_muc_log/mod_http_muc_log.lua
changeset 4680 a2cf3b69a3d6
parent 4596 38f501dca618
child 4681 823370bc2e4c
--- 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);