diff --git a/time_restricted/mod_time_restricted.lua b/time_restricted/mod_time_restricted.lua index 8ea78bb..39dee5d 100644 --- a/time_restricted/mod_time_restricted.lua +++ b/time_restricted/mod_time_restricted.lua @@ -17,19 +17,28 @@ module:hook("muc-room-created", function (event) -- announce the expiration time room:broadcast_message( - st.message({ type="groupchat", from=room.jid }) - :tag("body") - :text("The conference will be terminated in "..MIN.." min")) + st.message({ type="groupchat", from=room.jid }) + :tag("body") + :text("The conference will be terminated in "..MIN.." min")) - module:log(LOGLEVEL, "set timeout for conference, %s secs, %s", - TIMEOUT, room.jid) + module:log( + LOGLEVEL, "set timeout for conference, %s secs, %s", + TIMEOUT, + room.jid + ) timer.add_task(TIMEOUT, function() if is_healthcheck_room(room.jid) then return end + local occupant_count = it.count(room:each_occupant()) + if occupant_count == 0 then + return + end + -- terminate the meeting + room:set_persistent(false) room:destroy(nil, "The meeting has been terminated") module:log(LOGLEVEL, "the conference terminated") end)