Created
September 13, 2021 14:42
-
-
Save shawnchin/68d60a84d680e963a8a0352c71b91e5c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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