You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

mod_jiconop.lua 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. local st = require "util.stanza";
  2. local get_services = module:depends("external_services").get_services;
  3. -- Jitsi Connection Optimization
  4. -- gathers needed information and pushes it with a message to clients
  5. -- this way we skip 4 request responses during every client setup
  6. local shard_name_config = module:get_option_string('shard_name');
  7. if shard_name_config then
  8. module:add_identity("server", "shard", shard_name_config);
  9. end
  10. -- this is after xmpp-bind, the moment a client has resource and can be contacted
  11. module:hook("resource-bind", function (event)
  12. local session = event.session;
  13. -- disco info data / all identity and features
  14. local query = st.stanza("query", { xmlns = "http://jabber.org/protocol/disco#info" });
  15. local done = {};
  16. for _,identity in ipairs(module:get_host_items("identity")) do
  17. local identity_s = identity.category.."\0"..identity.type;
  18. if not done[identity_s] then
  19. query:tag("identity", identity):up();
  20. done[identity_s] = true;
  21. end
  22. end
  23. -- check whether room has lobby enabled and display name is required for those trying to join
  24. local lobby_muc_component_config = module:get_option_string('lobby_muc');
  25. module:context(lobby_muc_component_config):fire_event('host-disco-info-node',
  26. {origin = session; reply = query; node = 'lobbyrooms';});
  27. local stanza = st.message({
  28. from = module.host;
  29. to = session.full_jid; });
  30. stanza:add_child(query):up();
  31. --- get turnservers and credentials
  32. local services = get_services();
  33. stanza:tag("services");
  34. for _, srv in ipairs(services) do
  35. stanza:tag("service", srv):up();
  36. end
  37. session.send(stanza);
  38. end);