Hi to all!
I want to develop a custom module for jitsi for logging to an external database the joining and the leaving of my users.
This is the simple code that I have writed.
It not work what is wrong in my code?
local is_healthcheck_room = module:require "util".is_healthcheck_room;
local muc_component_host = module:get_option_string("muc_component");
if muc_component_host == nil then
log("error", "No muc_component specified. No muc to operate on!");
return;
end
module:log("info", "Hello from MyModule prosody module!");
function occupant_joined(event)
module:log("info", "occupant_joined");
end
function occupant_leaving(event)
module:log("info", "occupant_leaving");
end
function process_host(host)
if host == muc_component_host then -- the conference muc component
module:log("info","Hook to muc events on %s", host);
local muc_module = module:context(host);
muc_module:hook("muc-occupant-joined", occupant_joined, -1);
muc_module:hook("muc-occupant-pre-leave", occupant_leaving, -1);
end
end
if prosody.hosts[muc_component_host] == nil then
module:log("info","No muc component found, will listen for it: %s", muc_component_host);
prosody.events.add_handler("host-activated", process_host);
else
process_host(muc_component_host);
end
function occupant_joined(event)
module:log("info", "occupant_joined");
end
function occupant_leaving(event)
module:log("info", "occupant_leaving");
end
module:hook("muc-occupant-joined", occupant_joined, -1);
module:hook("muc-occupant-pre-leave", occupant_leaving, -1);
With this configuration I don’t see at startup in the console of the prosody container:
Hello from MyModule prosody module!
And I don’t see also occupant_joined and occupant_leaving when an user join or leave.
It doesn’t seem to load at all
EDIT 1: I checked in the files ~/jitsi-meet-cfg/prosody/config/conf.d/jitsi-meet.cfg.lua and I see correctly the name of my module under muc component.
EDIT 2: I don’t see errors in the console.
EDIT 1: fixed first issue, in docker jitsi the muc is: muc.meet.jitsi not conference.meet.jitsi
Now I see the events in prosody console:
prosody_1 | event_sync.meet.jitsi:event_sync_component info Start tracking occupants for endlessrepeatsstartout@muc.meet.jitsi
prosody_1 | event_sync.meet.jitsi:event_sync_component info New occupant - {"occupant_jid":"f2dd9zkrbbvnwlq_kty-j7ba@meet.jitsi/NO83jqXMg35a","joined_at":1669981819}
prosody_1 | event_sync.meet.jitsi:event_sync_component info Room destroyed - endlessrepeatsstartout@muc.meet.jitsi
but I don’t see in my database the rows. the API is working, I am sure! I tested it with postman.
EDIT 2: found the final issue:
api_prefix = "https://myurlapy.app/api/v1"
api_prefix don’t need the final / now it works great!!