Skip to content

Instantly share code, notes, and snippets.

@shawnchin
Created September 13, 2021 14:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save shawnchin/68d60a84d680e963a8a0352c71b91e5c to your computer and use it in GitHub Desktop.
Save shawnchin/68d60a84d680e963a8a0352c71b91e5c to your computer and use it in GitHub Desktop.
local jid = require("util.jid")
local is_healthcheck_room = module:require 'util'.is_healthcheck_room;
local max_occupants_for_room = module:get_option("max_occupants_for_room", {});
if next(max_occupants_for_room) ~= nil then
module:hook("muc-room-created", function(event)
local room = event.room;
if is_healthcheck_room(room.jid) then
return;
end
local room_name = jid.node(room.jid)
for configured_room, max_occupant in pairs(max_occupants_for_room) do
if configured_room == room_name then -- if room name matches entry in max_occupants_for_room
module:log("info", "Limiting room %s to max_occupants %d", configured_room, max_occupant);
room._data.max_occupants = max_occupant;
break;
end
end
end);
else
module:log("info", "max_occupants_for_room not configured. Nothing to do.");
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment