"Fossies" - the Fresh Open Source Software Archive

Member "jitsi-meet-7316/resources/prosody-plugins/mod_jiconop.lua" (5 Jun 2023, 2332 Bytes) of package /linux/misc/jitsi-meet-7316.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Lua source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 local st = require "util.stanza";
    2 local ext_services = module:depends("external_services");
    3 local get_services = ext_services.get_services;
    4 local services_xml = ext_services.services_xml;
    5 
    6 -- Jitsi Connection Optimization
    7 -- gathers needed information and pushes it with a message to clients
    8 -- this way we skip 4 request responses during every client setup
    9 
   10 local shard_name_config = module:get_option_string('shard_name');
   11 if shard_name_config then
   12     module:add_identity("server", "shard", shard_name_config);
   13 end
   14 
   15 local region_name_config = module:get_option_string('region_name');
   16 if region_name_config then
   17     module:add_identity("server", "region", region_name_config);
   18 end
   19 
   20 local release_number_config = module:get_option_string('release_number');
   21 if release_number_config then
   22     module:add_identity("server", "release", release_number_config);
   23 end
   24 
   25 -- we cache the query as server identities will not change dynamically, amd use its clone every time
   26 local query_cache;
   27 
   28 -- this is after xmpp-bind, the moment a client has resource and can be contacted
   29 module:hook("resource-bind", function (event)
   30     local session = event.session;
   31 
   32     if query_cache == nil then
   33         -- disco info data / all identity and features
   34         local query = st.stanza("query", { xmlns = "http://jabber.org/protocol/disco#info" });
   35         local done = {};
   36         for _,identity in ipairs(module:get_host_items("identity")) do
   37             local identity_s = identity.category.."\0"..identity.type;
   38             if not done[identity_s] then
   39                 query:tag("identity", identity):up();
   40                 done[identity_s] = true;
   41             end
   42         end
   43 
   44         query_cache = query;
   45     end
   46 
   47     local query = st.clone(query_cache);
   48 
   49     -- check whether room has lobby enabled and display name is required for those trying to join
   50     local lobby_muc_component_config = module:get_option_string('lobby_muc');
   51     module:context(lobby_muc_component_config):fire_event('host-disco-info-node',
   52             {origin = session; reply = query; node = 'lobbyrooms';});
   53 
   54     local stanza = st.message({
   55             from = module.host;
   56             to = session.full_jid; });
   57     stanza:add_child(query):up();
   58 
   59     --- get turnservers and credentials
   60     stanza:add_child(services_xml(get_services()));
   61 
   62     session.send(stanza);
   63 end);