2021-04-22 17:54:34 +00:00
|
|
|
local st = require "util.stanza";
|
2022-03-29 16:59:14 +00:00
|
|
|
local ext_services = module:depends("external_services");
|
|
|
|
local get_services = ext_services.get_services;
|
|
|
|
local services_xml = ext_services.services_xml;
|
2021-04-22 17:54:34 +00:00
|
|
|
|
|
|
|
-- Jitsi Connection Optimization
|
|
|
|
-- gathers needed information and pushes it with a message to clients
|
|
|
|
-- this way we skip 4 request responses during every client setup
|
|
|
|
|
|
|
|
local shard_name_config = module:get_option_string('shard_name');
|
|
|
|
if shard_name_config then
|
|
|
|
module:add_identity("server", "shard", shard_name_config);
|
|
|
|
end
|
|
|
|
|
2021-10-07 11:49:15 +00:00
|
|
|
local region_name_config = module:get_option_string('region_name');
|
|
|
|
if region_name_config then
|
|
|
|
module:add_identity("server", "region", region_name_config);
|
|
|
|
end
|
|
|
|
|
2022-05-18 18:04:49 +00:00
|
|
|
local release_number_config = module:get_option_string('release_number');
|
|
|
|
if release_number_config then
|
|
|
|
module:add_identity("server", "release", release_number_config);
|
|
|
|
end
|
|
|
|
|
2022-11-28 20:18:59 +00:00
|
|
|
-- we cache the query as server identities will not change dynamically, amd use its clone every time
|
|
|
|
local query_cache;
|
|
|
|
|
2021-04-22 17:54:34 +00:00
|
|
|
-- this is after xmpp-bind, the moment a client has resource and can be contacted
|
|
|
|
module:hook("resource-bind", function (event)
|
|
|
|
local session = event.session;
|
|
|
|
|
2022-11-28 20:18:59 +00:00
|
|
|
if query_cache == nil then
|
|
|
|
-- disco info data / all identity and features
|
|
|
|
local query = st.stanza("query", { xmlns = "http://jabber.org/protocol/disco#info" });
|
|
|
|
local done = {};
|
|
|
|
for _,identity in ipairs(module:get_host_items("identity")) do
|
|
|
|
local identity_s = identity.category.."\0"..identity.type;
|
|
|
|
if not done[identity_s] then
|
|
|
|
query:tag("identity", identity):up();
|
|
|
|
done[identity_s] = true;
|
|
|
|
end
|
2021-04-22 17:54:34 +00:00
|
|
|
end
|
2022-11-28 20:18:59 +00:00
|
|
|
|
|
|
|
query_cache = query;
|
2021-04-22 17:54:34 +00:00
|
|
|
end
|
|
|
|
|
2022-11-28 20:18:59 +00:00
|
|
|
local query = st.clone(query_cache);
|
|
|
|
|
2021-04-22 17:54:34 +00:00
|
|
|
-- check whether room has lobby enabled and display name is required for those trying to join
|
|
|
|
local lobby_muc_component_config = module:get_option_string('lobby_muc');
|
|
|
|
module:context(lobby_muc_component_config):fire_event('host-disco-info-node',
|
|
|
|
{origin = session; reply = query; node = 'lobbyrooms';});
|
|
|
|
|
|
|
|
local stanza = st.message({
|
|
|
|
from = module.host;
|
|
|
|
to = session.full_jid; });
|
|
|
|
stanza:add_child(query):up();
|
|
|
|
|
|
|
|
--- get turnservers and credentials
|
2022-03-29 16:59:14 +00:00
|
|
|
stanza:add_child(services_xml(get_services()));
|
2021-04-22 17:54:34 +00:00
|
|
|
|
|
|
|
session.send(stanza);
|
|
|
|
end);
|