Mod_time_restricted doesn't work?

Hello.

I implemented the mod_time_restricted made by @emrah in october 2020. I restarted prosody and jicofo and I started a new meet. I’m waiting but, when past the time (I put 2 minutes) the meet don’t finish.

mod_time_restricted.lua

I put the images

config

Looking var/log/jitsi/jicofon.log I don’t see anything wrong. What I have to do?

Did you test with 2 or more participants?

What is your prosody version? I only tested it with prosody 0.11+

Hi @emrah .

Yes, I tested with myself (in one terminal using Windows and another terminal using Mac) and with the mic enabled in one of them.

Prosody version? I don’t know how can I check :confused:

dpkg -l 'prosody*'

Ok, I have this results

Your installed prosody is version 0.10.0 I think this is the problem.

Yes, you’re right. I updated Prosody to the last version and it works.

Thanks!

1 Like

@emrah a quick question. When you’re kicking the people, exists the possibility to redirect to another page?

We have a “closed” page that appears when the meet finish. So, how I can tell in the for when kick the participants that goes to this page?

For example:

-- kick all participants
for _, p in room:each_occupant() do
	if not _is_admin(p.jid) then
		room:set_affiliation(true, p.jid, "outcast")
		room:redirect_to('pageclosed.html')
		module:log(LOGLEVEL, "kick the occupant, %s", p.jid)
	end
end

How can do this?

Hello @emrah .

I tried your response but now the time_expired doesn’t appear in the meet. I think that something it’s wrong.

2021-02-18_08h43_58

local function redirect() {                           
    window.location.href="https://community.jitsi.org/";
}   

module:hook("muc-room-created", function (event)
    local room = event.room

    if is_healthcheck_room(room.jid) then
        module:log(LOGLEVEL, "skip restriction")
        return
    end

    -- 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"))

    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

        -- kick all participants
        for _, p in room:each_occupant() do
            if not _is_admin(p.jid) then
                room:set_affiliation(true, p.jid, "outcast")
				APP.conference._room.on("conference.kicked", redirect);
				APP.conference._room.on("conference.left", redirect);
                module:log(LOGLEVEL, "kick the occupant, %s", p.jid)
            end
        end

        module:log(LOGLEVEL, "the conference terminated")
    end)
end)

What’s the problem? :confused:

The response is not related with Prosody module code. It’s a seperate file /usr/share/jitsi-meet/body.html

Sorry, I didn’t understand you :frowning:

Don’t change anything on mod_time_restricted.lua

Open /usr/share/jitsi-meet/body.html file on your Jitsi server and add the following contents

<script>                                        
function redirect() {                           
    window.location.href="https://community.jitsi.org/";
}                                               
                                                
function subscribeToEvents() {                  
    try {                                       
        if (!APP.store.getState()) {            
            throw new Error("state is not ready. try again");
        } else if (!APP.store.getState()["features/base/connection"]) {
            throw new Error("connection is not ready. try again");
        }                                       
                                                
        cnn = APP.store.getState()["features/base/connection"];
        if (cnn.error) {                        
            return redirect();                  
        }                                       
                                                
        APP.conference._room.on("conference.kicked", redirect);
        APP.conference._room.on("conference.left", redirect);
    } catch(e) {                                
        setTimeout(() => subscribeToEvents(), 3000);
    }                                           
}                                               
                                                
subscribeToEvents();                            
</script> 
1 Like

Oh, sorry, now I understand you. I implemented, tested and it works!

Thank you emrah :slight_smile:

1 Like

updated version

/usr/share/jitsi-meet/body.html

<script>                                        
function redirect() {                           
    window.location.href="https://community.jitsi.org/";
}                                               
                                                
function subscribeToEvents() {                  
    try {                                       
        if (!APP.store.getState()) {            
            throw new Error("state is not ready. try again");
        } else if (!APP.store.getState()["features/base/connection"]) {
            throw new Error("connection is not ready. try again");
        }                                       
                                                
        cnn = APP.store.getState()["features/base/connection"];
        if (cnn.error) {                        
            return redirect();                  
        }                                       
                                                
        APP.conference._room.on("conference.failed", redirect);
        APP.conference._room.on("conference.kicked", redirect);
        APP.conference._room.on("conference.left", redirect);
    } catch(e) {                                
        setTimeout(() => subscribeToEvents(), 3000);
    }                                           
}                                               
                                                
subscribeToEvents();                            
</script>

edit: the conference.failed event added

1 Like

It’s exactly this. Thank you very much.

Just one thing.
I opened a conference, 2 people (same pc, different browsers) with the exactly same jwt.
When one person left, it says on his own browser that himself is out but it says the other guy is left (listener user_left). “UnhandledError: RTCPeerConnection is gone (did you enter Offline mode?)”
In the other browser (the one that didn’t left), it seems correct.

Maybe it’s because the same jwt?

Thank you.

Hi,
Hope you are doing well.

Would you please guide me as to where in particular you have enabled the mod_time_restricted module in prosody ?

i have added at the end of the file the configuration similar to yours for my domain name. However, it did not work and there is no error as well for jicofo or prosody.

It worked. Much thanks. I was manually adding this module before. God bless you.

1 Like