Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
chore(prosody): Remove deprecated modules. (#17453)
bgrozev20021d1a2fc8
diff --git a/resources/prosody-plugins/README.md b/resources/prosody-plugins/README.mdindex 97f2465536..65ea1f60fc 100644--- a/resources/prosody-plugins/README.md+++ b/resources/prosody-plugins/README.md@@ -38,7 +38,7 @@- av_moderation_startMuted_restore - Keeps the startMuted metadata state of the room before AV moderation was applied. Used by mod_av_moderation_component.lua.- broadcast_timer - A timer used to broadcast the list of breakout rooms in the main room. It is set by mod_muc_breakout_rooms.lua to periodically update the list of breakout rooms.- close_timer - A timer used to close the main room when all occupants have left. It is set by mod_muc_breakout_rooms.lua to clean up the main room after all participants left from breakout room.-- created_timestamp - A timestamp in milliseconds when the room was created. It is set by mod_conference_duration_component.lua and used by mod_conference_duration.lua to calculate the conference duration. It is also used by mod_measure_message_count.lua to calculate the room duration for analytics.+- created_timestamp - A timestamp in milliseconds when the room was created. It is set by mod_conference_duration.lua and used to calculate the conference duration. It is also used by mod_measure_message_count.lua to calculate the room duration for analytics.- has_host - Whether the host (an authenticated user) has arrived in the room.- is_vpaas - A boolean value indicating whether the room is a VPAAS room, optimization for the is_vpaas function in util.internal.lib.lua.- jibri_throttle - A throttle object used to limit the number of Jibri requests per room. It is created in mod_filter_iq_jibri.lua to prevent abuse of Jibri resources.diff --git a/resources/prosody-plugins/mod_av_moderation.lua b/resources/prosody-plugins/mod_av_moderation.luadeleted file mode 100644index 817fdb7b00..0000000000--- a/resources/prosody-plugins/mod_av_moderation.lua+++ /dev/null@@ -1,6 +0,0 @@--- TODO: Remove this file after several stable releases when people update their configs-module:log('warn', 'mod_av_moderation is deprecated and will be removed in a future release. '- .. 'Please update your config by removing this module from the list of loaded modules.');--module:depends('jitsi_session');-module:depends('features_identity');diff --git a/resources/prosody-plugins/mod_conference_duration_component.lua b/resources/prosody-plugins/mod_conference_duration_component.luadeleted file mode 100644index d643dc23c7..0000000000--- a/resources/prosody-plugins/mod_conference_duration_component.lua+++ /dev/null@@ -1,47 +0,0 @@--- DEPRECATED and will be removed, giving time for mobile clients to update-local st = require "util.stanza";-local socket = require "socket";-local json = require 'cjson.safe';-local it = require "util.iterators";-local process_host_module = module:require "util".process_host_module;---- we use async to detect Prosody 0.10 and earlier-local have_async = pcall(require, "util.async");-if not have_async then- module:log("warn", "conference duration will not work with Prosody version 0.10 or less.");- return;-end--local muc_component_host = module:get_option_string("muc_component");-if muc_component_host == nil then- module:log("error", "No muc_component specified. No muc to operate on!");- return;-end--module:log("info", "Starting conference duration timer for %s", muc_component_host);--function occupant_joined(event)- local room = event.room;- local occupant = event.occupant;-- local participant_count = it.count(room:each_occupant());-- if participant_count > 1 then- local body_json = {};- body_json.type = 'conference_duration';- body_json.created_timestamp = room.created_timestamp;-- local stanza = st.message({- from = module.host;- to = occupant.jid;- })- :tag("json-message", {xmlns='http://jitsi.org/jitmeet'})- :text(json.encode(body_json)):up();-- room:route_stanza(stanza);- end-end--process_host_module(muc_component_host, function(host_module, host)- host_module:hook("muc-occupant-joined", occupant_joined, -1);-end);diff --git a/resources/prosody-plugins/mod_muc_call.lua b/resources/prosody-plugins/mod_muc_call.luadeleted file mode 100644index c989d902cf..0000000000--- a/resources/prosody-plugins/mod_muc_call.lua+++ /dev/null@@ -1,125 +0,0 @@-local jid = require "util.jid"-local extract_subdomain = module:require "util".extract_subdomain;---- Options and configuration-local poltergeist_component = module:get_option_string(- "poltergeist_component",- module.host-);-local muc_domain_base = module:get_option_string("muc_mapper_domain_base");-if not muc_domain_base then- module:log(- "warn",- "No 'muc_domain_base' option set, unable to send call events."- );- return-end---- Status strings that trigger call events.-local calling_status = "calling"-local busy_status = "busy"-local rejected_status = "rejected"-local connected_status = "connected"-local expired_status = "expired"---- url_from_room_jid will determine the url for a conference--- provided a room jid. It is required that muc domain mapping--- is enabled and configured. There are two url formats that are supported.--- The following urls are examples of the supported formats.--- https://meet.jit.si/jitsi/ProductiveMeeting--- https://meet.jit.si/MoreProductiveMeeting--- The urls are derived from portions of the room jid.-local function url_from_room_jid(room_jid)- local node, _, _ = jid.split(room_jid)- if not node then return nil end-- local target_subdomain, target_node = extract_subdomain(node);-- if not(target_node or target_subdomain) then- return "https://"..muc_domain_base.."/"..node- else- return "https://"..muc_domain_base.."/"..target_subdomain.."/"..target_node- end-end---- Listening for all muc presences stanza events. If a presence stanza is from--- a poltergeist then it will be further processed to determine if a call--- event should be triggered. Call events are triggered by status strings--- the status strings supported are:--- ---------------------------- Status | Event Type--- _________________________--- "calling" | INVITE--- "busy" | CANCEL--- "rejected" | CANCEL--- "connected" | CANCEL-module:hook(- "muc-broadcast-presence",- function (event)- -- Detect if the presence is for a poltergeist or not.- -- FIX ME: luacheck warning 581- -- not (x == y)' can be replaced by 'x ~= y' (if neither side is a table or NaN)- if not (jid.bare(event.occupant.jid) == poltergeist_component) then- return- end-- -- A presence stanza is needed in order to trigger any calls.- if not event.stanza then- return- end-- local call_id = event.stanza:get_child_text("call_id")- if not call_id then- module:log("info", "A call id was not provided in the status.")- return- end-- local invite = function()- local url = assert(url_from_room_jid(event.stanza.attr.from))- module:fire_event('jitsi-call-invite', { stanza = event.stanza; url = url; call_id = call_id; });- end-- local cancel = function()- local url = assert(url_from_room_jid(event.stanza.attr.from))- local status = event.stanza:get_child_text("status")- module:fire_event('jitsi-call-cancel', {- stanza = event.stanza;- url = url;- reason = string.lower(status);- call_id = call_id;- });- end-- -- If for any reason call_cancel is set to true then a cancel- -- is sent regardless of the rest of the presence info.- local should_cancel = event.stanza:get_child_text("call_cancel")- if should_cancel == "true" then- cancel()- return- end-- local missed = function()- cancel()- module:fire_event('jitsi-call-missed', { stanza = event.stanza; call_id = call_id; });- end-- -- All other call flow actions will require a status.- if event.stanza:get_child_text("status") == nil then- return- end-- local switch = function(status)- case = {- [calling_status] = function() invite() end,- [busy_status] = function() cancel() end,- [rejected_status] = function() missed() end,- [expired_status] = function() missed() end,- [connected_status] = function() cancel() end- }- if case[status] then case[status]() end- end-- switch(event.stanza:get_child_text("status"))- end,- -101-);diff --git a/resources/prosody-plugins/mod_muc_poltergeist.lua b/resources/prosody-plugins/mod_muc_poltergeist.luadeleted file mode 100644index b9fa4a6946..0000000000--- a/resources/prosody-plugins/mod_muc_poltergeist.lua+++ /dev/null@@ -1,319 +0,0 @@-local bare = require "util.jid".bare;-local get_room_by_name_and_subdomain = module:require "util".get_room_by_name_and_subdomain;-local jid = require "util.jid";-local neturl = require "net.url";-local parse = neturl.parseQuery;-local poltergeist = module:require "poltergeist";--local have_async = pcall(require, "util.async");-if not have_async then- module:log("error", "requires a version of Prosody with util.async");- return;-end--module:depends("jitsi_session");--local async_handler_wrapper = module:require "util".async_handler_wrapper;---- Options-local poltergeist_component- = module:get_option_string("poltergeist_component", module.host);---- this basically strips the domain from the conference.domain address-local parentHostName = string.gmatch(tostring(module.host), "%w+.(%w.+)")();-if parentHostName == nil then- log("error", "Failed to start - unable to get parent hostname");- return;-end--local parentCtx = module:context(parentHostName);-if parentCtx == nil then- log("error",- "Failed to start - unable to get parent context for host: %s",- tostring(parentHostName));- return;-end-local token_util = module:require "token/util".new(parentCtx);---- option to enable/disable token verifications-local disableTokenVerification- = module:get_option_boolean("disable_polergeist_token_verification", false);---- poltergaist management functions----- Verifies room name, domain name with the values in the token--- @param token the token we received--- @param room_name the room name--- @param group name of the group (optional)--- @param session the session to use for storing token specific fields--- @return true if values are ok or false otherwise-function verify_token(token, room_name, group, session)- if disableTokenVerification then- return true;- end-- -- if not disableTokenVerification and we do not have token- -- stop here, cause the main virtual host can have guest access enabled- -- (allowEmptyToken = true) and we will allow access to rooms info without- -- a token- if token == nil then- log("warn", "no token provided");- return false;- end-- session.auth_token = token;- local verified, reason = token_util:process_and_verify_token(session);- if not verified then- log("warn", "not a valid token %s", tostring(reason));- return false;- end-- local room_address = jid.join(room_name, module:get_host());- -- if there is a group we are in multidomain mode and that group is not- -- our parent host- if group and group ~= "" and group ~= parentHostName then- room_address = "["..group.."]"..room_address;- end-- if not token_util:verify_room(session, room_address) then- log("warn", "Token %s not allowed to join: %s",- tostring(token), tostring(room_address));- return false;- end-- return true;-end---- Event handlers---- if we found that a session for a user with id has a poltergiest already--- created, retrieve its jid and return it to the authentication--- so we can reuse it and we that real user will replace the poltergiest-prosody.events.add_handler("pre-jitsi-authentication", function(session)-- if (session.jitsi_meet_context_user) then- local room = get_room_by_name_and_subdomain(- session.jitsi_web_query_room,- session.jitsi_web_query_prefix);-- if (not room) then- return nil;- end-- local username = poltergeist.get_username(- room,- session.jitsi_meet_context_user["id"]- );-- if (not username) then- return nil;- end-- log("debug", "Found predefined username %s", username);-- -- let's find the room and if the poltergeist occupant is there- -- lets remove him before the real participant joins- -- when we see the unavailable presence to go out the server- -- we will mark it with ignore tag- local nick = poltergeist.create_nick(username);- if (poltergeist.occupies(room, nick)) then- module:log("info", "swapping poltergeist for user: %s/%s", room, nick)- -- notify that user connected using the poltergeist- poltergeist.update(room, nick, "connected");- poltergeist.remove(room, nick, true);- end-- return username;- end-- return nil;-end);----- Note: mod_muc and some of its sub-modules add event handlers between 0 and -100,---- e.g. to check for banned users, etc.. Hence adding these handlers at priority -100.-module:hook("muc-decline", function (event)- poltergeist.remove(event.room, bare(event.stanza.attr.from), false);-end, -100);--- before sending the presence for a poltergeist leaving add ignore tag--- as poltergeist is leaving just before the real user joins and in the client--- we ignore this presence to avoid leaving/joining experience and the real--- user will reuse all currently created UI components for the same nick-module:hook("muc-broadcast-presence", function (event)- if (bare(event.occupant.jid) == poltergeist_component) then- if(event.stanza.attr.type == "unavailable"- and poltergeist.should_ignore(event.occupant.nick)) then- event.stanza:tag(- "ignore", { xmlns = "http://jitsi.org/jitmeet/" }):up();- poltergeist.reset_ignored(event.occupant.nick);- end- end-end, -100);---- cleanup room table after room is destroyed-module:hook(- "muc-room-destroyed",- function(event)- poltergeist.remove_room(event.room);- end-);----- Handles request for creating/managing poltergeists--- @param event the http event, holds the request query--- @return GET response, containing a json with response details-function handle_create_poltergeist (event)- if (not event.request.url.query) then- return { status_code = 400; };- end-- local params = parse(event.request.url.query);- local user_id = params["user"];- local room_name = params["room"];- local group = params["group"];- local name = params["name"];- local avatar = params["avatar"];- local status = params["status"];- local conversation = params["conversation"];- local session = {};-- if not verify_token(params["token"], room_name, group, session) then- return { status_code = 403; };- end-- -- If the provided room conference doesn't exist then we- -- can't add a poltergeist to it.- local room = get_room_by_name_and_subdomain(room_name, group);- if (not room) then- log("error", "no room found %s", room_name);- return { status_code = 404; };- end-- -- If the poltergiest is already in the conference then it will- -- be in our username store and another can't be added.- local username = poltergeist.get_username(room, user_id);- if (username ~=nil and- poltergeist.occupies(room, poltergeist.create_nick(username))) then- log("warn",- "poltergeist for username:%s already in the room:%s",- username,- room_name- );- return { status_code = 202; };- end-- local context = {- user = {- id = user_id;- };- group = group;- creator_user = session.jitsi_meet_context_user;- creator_group = session.jitsi_meet_context_group;- };- if avatar ~= nil then- context.user.avatar = avatar- end- local resources = {};- if conversation ~= nil then- resources["conversation"] = conversation- end-- poltergeist.add_to_muc(room, user_id, name, avatar, context, status, resources)- return { status_code = 200; };-end----- Handles request for updating poltergeists status--- @param event the http event, holds the request query--- @return GET response, containing a json with response details-function handle_update_poltergeist (event)- if (not event.request.url.query) then- return { status_code = 400; };- end-- local params = parse(event.request.url.query);- local user_id = params["user"];- local room_name = params["room"];- local group = params["group"];- local status = params["status"];- local call_id = params["callid"];-- local call_cancel = false- if params["callcancel"] == "true" then- call_cancel = true;- end-- if not verify_token(params["token"], room_name, group, {}) then- return { status_code = 403; };- end-- local room = get_room_by_name_and_subdomain(room_name, group);- if (not room) then- log("error", "no room found %s", room_name);- return { status_code = 404; };- end-- local username = poltergeist.get_username(room, user_id);- if (not username) then- return { status_code = 404; };- end-- local call_details = {- ["cancel"] = call_cancel;- ["id"] = call_id;- };-- local nick = poltergeist.create_nick(username);- if (not poltergeist.occupies(room, nick)) then- return { status_code = 404; };- end-- poltergeist.update(room, nick, status, call_details);- return { status_code = 200; };-end----- Handles remove poltergeists--- @param event the http event, holds the request query--- @return GET response, containing a json with response details-function handle_remove_poltergeist (event)- if (not event.request.url.query) then- return { status_code = 400; };- end-- local params = parse(event.request.url.query);- local user_id = params["user"];- local room_name = params["room"];- local group = params["group"];-- if not verify_token(params["token"], room_name, group, {}) then- return { status_code = 403; };- end-- local room = get_room_by_name_and_subdomain(room_name, group);- if (not room) then- log("error", "no room found %s", room_name);- return { status_code = 404; };- end-- local username = poltergeist.get_username(room, user_id);- if (not username) then- return { status_code = 404; };- end-- local nick = poltergeist.create_nick(username);- if (not poltergeist.occupies(room, nick)) then- return { status_code = 404; };- end-- poltergeist.remove(room, nick, false);- return { status_code = 200; };-end--log("info", "Loading poltergeist service");-module:depends("http");-module:provides("http", {- default_path = "/";- name = "poltergeist";- route = {- ["GET /poltergeist/create"] = function (event) return async_handler_wrapper(event,handle_create_poltergeist) end;- ["GET /poltergeist/update"] = function (event) return async_handler_wrapper(event,handle_update_poltergeist) end;- ["GET /poltergeist/remove"] = function (event) return async_handler_wrapper(event,handle_remove_poltergeist) end;- };-});diff --git a/resources/prosody-plugins/mod_poltergeist_component.lua b/resources/prosody-plugins/mod_poltergeist_component.luadeleted file mode 100644index aa06175dba..0000000000--- a/resources/prosody-plugins/mod_poltergeist_component.lua+++ /dev/null@@ -1,21 +0,0 @@-local st = require "util.stanza";---- A component which we use to receive all stanzas for the created poltergeists--- replays with error if an iq is sent-function no_action()- return true;-end--function error_reply(event)- module:send(st.error_reply(event.stanza, "cancel", "service-unavailable"));- return true;-end--module:hook("presence/host", no_action);-module:hook("message/host", no_action);-module:hook("presence/full", no_action);-module:hook("message/full", no_action);--module:hook("iq/host", error_reply);-module:hook("iq/full", error_reply);-module:hook("iq/bare", error_reply);diff --git a/resources/prosody-plugins/mod_room_metadata.lua b/resources/prosody-plugins/mod_room_metadata.luadeleted file mode 100644index a024965d76..0000000000--- a/resources/prosody-plugins/mod_room_metadata.lua+++ /dev/null@@ -1,6 +0,0 @@--- TODO: Remove this file after several stable releases when people update their configs-module:log('warn', 'mod_room_metadata is deprecated and will be removed in a future release. '- .. 'Please update your config by removing this module from the list of loaded modules.');--module:depends("jitsi_session");-module:depends("features_identity");diff --git a/resources/prosody-plugins/mod_speakerstats.lua b/resources/prosody-plugins/mod_speakerstats.luadeleted file mode 100644index 380fde4aed..0000000000--- a/resources/prosody-plugins/mod_speakerstats.lua+++ /dev/null@@ -1,6 +0,0 @@--- TODO: Remove this file after several stable releases when people update their configs-module:log('warn', 'mod_speakerstats is deprecated and will be removed in a future release. '- .. 'Please update your config by removing this module from the list of loaded modules.');--module:depends('jitsi_session');-module:depends('features_identity');diff --git a/resources/prosody-plugins/mod_turncredentials.lua b/resources/prosody-plugins/mod_turncredentials.luadeleted file mode 100644index aeec02b0d5..0000000000--- a/resources/prosody-plugins/mod_turncredentials.lua+++ /dev/null@@ -1,85 +0,0 @@--- XEP-0215 implementation for time-limited turn credentials--- Copyright (C) 2012-2014 Philipp Hancke--- This file is MIT/X11 licensed.------ Note: Prosody's built-in external_services module and mod_turncredentials_http--- (which depends on external_services) both hook the same urn:xmpp:extdisco:1--- IQ event. If any of these are loaded on the same VirtualHost they will override--- this module. Only one of the three should be configured on a given VirtualHost.----turncredentials_secret = "keepthissecret";---turncredentials = {--- { type = "stun", host = "8.8.8.8" },--- { type = "turn", host = "8.8.8.8", port = "3478" },--- { type = "turn", host = "8.8.8.8", port = "80", transport = "tcp" }---}--- for stun servers, host is required, port defaults to 3478--- for turn servers, host is required, port defaults to tcp,--- transport defaults to udp--- hosts can be a list of server names / ips for random--- choice loadbalancing--local st = require "util.stanza";-local hmac_sha1 = require "util.hashes".hmac_sha1;-local base64 = require "util.encodings".base64;-local os_time = os.time;-local secret = module:get_option_string("turncredentials_secret");-local ttl = module:get_option_number("turncredentials_ttl", 86400);-local hosts = module:get_option("turncredentials") or {};-if not (secret) then- module:log("error", "turncredentials not configured");- return;-end--module:add_feature("urn:xmpp:extdisco:1");--function random(arr)- local index = math.random(1, #arr);- return arr[index];-end---module:hook_global("config-reloaded", function()- module:log("debug", "config-reloaded")- secret = module:get_option_string("turncredentials_secret");- ttl = module:get_option_number("turncredentials_ttl", 86400);- hosts = module:get_option("turncredentials") or {};-end);--module:hook("iq-get/host/urn:xmpp:extdisco:1:services", function(event)- local origin, stanza = event.origin, event.stanza;- if origin.type ~= "c2s" then- return;- end- local now = os_time() + ttl;- local userpart = tostring(now);- local nonce = base64.encode(hmac_sha1(secret, tostring(userpart), false));- local reply = st.reply(stanza):tag("services", {xmlns = "urn:xmpp:extdisco:1"})- for idx, item in pairs(hosts) do- if item.type == "stun" or item.type == "stuns" then- -- stun items need host and port (defaults to 3478)- reply:tag("service",- { type = item.type, host = item.host, port = tostring(item.port) or "3478" }- ):up();- elseif item.type == "turn" or item.type == "turns" then- local turn = {}- -- turn items need host, port (defaults to 3478),- -- transport (defaults to udp)- -- username, password, ttl- turn.type = item.type;- turn.port = tostring(item.port);- turn.transport = item.transport;- turn.username = userpart;- turn.password = nonce;- turn.ttl = tostring(ttl);- if item.hosts then- turn.host = random(item.hosts)- else- turn.host = item.host- end- reply:tag("service", turn):up();- end- end- origin.send(reply);- return true;-end);diff --git a/resources/prosody-plugins/poltergeist.lib.lua b/resources/prosody-plugins/poltergeist.lib.luadeleted file mode 100644index e44c785a3d..0000000000--- a/resources/prosody-plugins/poltergeist.lib.lua+++ /dev/null@@ -1,397 +0,0 @@-local inspect = require("inspect")-local jid = require("util.jid")-local stanza = require("util.stanza")-local timer = require("util.timer")-local update_presence_identity = module:require("util").update_presence_identity-local uuid = require("util.uuid")--local component = module:get_option_string(- "poltergeist_component",- module.host-)--local expiration_timeout = module:get_option_string(- "poltergeist_leave_timeout",- 30 -- defaults to 30 seconds-)--local MUC_NS = "http://jabber.org/protocol/muc"------------------------------------------------------------------------------------- Utility functions for commonly used poltergeist codes.------------------------------------------------------------------------------------- Creates a nick for a poltergeist.--- @param username is the unique username of the poltergeist--- @return a nick to use for xmpp-local function create_nick(username)- return string.sub(username, 0,8)-end---- Returns the last presence of the occupant.--- @param room the room instance where to check for occupant--- @param nick the nick of the occupant--- @return presence stanza of the occupant-function get_presence(room, nick)- local occupant_jid = room:get_occupant_jid(component.."/"..nick)- if occupant_jid then- return room:get_occupant_by_nick(occupant_jid):get_presence();- end- return nil;-end---- Checks for existence of a poltergeist occupant in a room.--- @param room the room instance where to check for the occupant--- @param nick the nick of the occupant--- @return true if occupant is found, false otherwise-function occupies(room, nick)- -- Find out if we have a poltergeist occupant in the room for this JID- return not not room:get_occupant_jid(component.."/"..nick);-end------------------------------------------------------------------------------------- Username storage for poltergeist.------ Every poltergeist will have a username stored in a table underneath--- the room name that they are currently active in. The username can--- be retrieved given a room and a user_id. The username is removed from--- a room by providing the room and the nick.------ A table with a single entry looks like:--- {--- ["[hug]hostilewerewolvesthinkslightly"] = {--- ["655363:52148a3e-b5fb-4cfc-8fbd-f55e793cf657"] = "ed7757d6-d88d-4e6a-8e24-aca2adc31348",--- ed7757d6 = "655363:52148a3e-b5fb-4cfc-8fbd-f55e793cf657"--- }--- }------------------------------------------------------------------------------------ state is the table where poltergeist usernames and call resources are stored--- for a given xmpp muc.-local state = module:shared("state")---- Adds a poltergeist to the store.--- @param room is the room the poltergeist is being added to--- @param user_id is the user_id of the user the poltergeist represents--- @param username is the unique id of the poltergeist itself-local function store_username(room, user_id, username)- local room_name = jid.node(room.jid)-- if not state[room_name] then- state[room_name] = {}- end-- state[room_name][user_id] = username- state[room_name][create_nick(username)] = user_id-end---- Retrieves a poltergeist username from the store if one exists.--- @param room is the room to check for the poltergeist in the store--- @param user_id is the user id of the user the poltergeist represents-local function get_username(room, user_id)- local room_name = jid.node(room.jid)-- if not state[room_name] then- return nil- end-- return state[room_name][user_id]-end--local function get_username_from_nick(room_name, nick)- if not state[room_name] then- return nil- end-- local user_id = state[room_name][nick]- return state[room_name][user_id]-end---- Removes the username from the store.--- @param room is the room the poltergeist is being removed from--- @param nick is the nick of the muc occupant-local function remove_username(room, nick)- local room_name = jid.node(room.jid)- if not state[room_name] then- return- end-- local user_id = state[room_name][nick]- state[room_name][user_id] = nil- state[room_name][nick] = nil-end---- Removes all poltergeists in the store for the provided room.--- @param room is the room all poltergiest will be removed from-local function remove_room(room)- local room_name = jid.node(room.jid)- if state[room_name] then- state[room_name] = nil- end-end---- Adds a resource that is associated with a a call in a room. There--- is only one resource for each type.--- @param room is the room the call and poltergeist is in.--- @param call_id is the unique id for the call.--- @param resource_type is type of resource being added.--- @param resource_id is the id of the resource being added.-local function add_call_resource(room, call_id, resource_type, resource_id)- local room_name = jid.node(room.jid)- if not state[room_name] then- state[room_name] = {}- end-- if not state[room_name][call_id] then- state[room_name][call_id] = {}- end-- state[room_name][call_id][resource_type] = resource_id-end------------------------------------------------------------------------------------- State for toggling the tagging of presence stanzas with ignored tag.------ A poltergeist with it's full room/nick set to ignore will have a jitsi ignore--- tag applied to all presence stanza's broadcasted. The following functions--- assist in managing this state.----------------------------------------------------------------------------------local presence_ignored = {}---- Sets the nick to ignored state.--- @param room_nick full room/nick jid-local function set_ignored(room_nick)- presence_ignored[room_nick] = true-end---- Resets the nick out of ignored state.--- @param room_nick full room/nick jid-local function reset_ignored(room_nick)- presence_ignored[room_nick] = nil-end---- Determines whether or not the leave presence should be tagged with ignored.--- @param room_nick full room/nick jid-local function should_ignore(room_nick)- if presence_ignored[room_nick] == nil then- return false- end- return presence_ignored[room_nick]-end------------------------------------------------------------------------------------- Poltergeist control functions for adding, updating and removing poltergeist.------------------------------------------------------------------------------------- Updates the status tags and call flow tags of an existing poltergeist--- presence.--- @param presence_stanza is the actual presence stanza for a poltergeist.--- @param status is the new status to be updated in the stanza.--- @param call_details is a table of call flow signal information.-function update_presence_tags(presence_stanza, status, call_details)- local call_cancel = false- local call_id = nil-- -- Extract optional call flow signal information.- if call_details then- call_id = call_details["id"]-- if call_details["cancel"] then- call_cancel = call_details["cancel"]- end- end-- presence_stanza:maptags(function (tag)- if tag.name == "status" then- if call_cancel then- -- If call cancel is set then the status should not be changed.- return tag- end- return stanza.stanza("status"):text(status)- elseif tag.name == "call_id" then- if call_id then- return stanza.stanza("call_id"):text(call_id)- else- -- If no call id is provided the re-use the existing id.- return tag- end- elseif tag.name == "call_cancel" then- if call_cancel then- return stanza.stanza("call_cancel"):text("true")- else- return stanza.stanza("call_cancel"):text("false")- end- end- return tag- end)-- return presence_stanza-end---- Updates the presence status of a poltergeist.--- @param room is the room the poltergeist has occupied--- @param nick is the xmpp nick of the poltergeist occupant--- @param status is the status string to set in the presence--- @param call_details is a table of call flow control details-local function update(room, nick, status, call_details)- local original_presence = get_presence(room, nick)-- if not original_presence then- module:log("info", "update issued for a non-existing poltergeist")- return- end-- -- update occupant presence with appropriate to and from- -- so we can send it again- update_presence = stanza.clone(original_presence)- update_presence.attr.to = room.jid.."/"..nick- update_presence.attr.from = component.."/"..nick-- update_presence = update_presence_tags(update_presence, status, call_details)-- module:log("info", "updating poltergeist: %s/%s - %s", room, nick, status)- room:handle_normal_presence(- prosody.hosts[component],- update_presence- )-end---- Removes the poltergeist from the room.--- @param room is the room the poltergeist has occupied--- @param nick is the xmpp nick of the poltergeist occupant--- @param ignore toggles if the leave subsequent leave presence should be tagged-local function remove(room, nick, ignore)- local original_presence = get_presence(room, nick);- if not original_presence then- module:log("info", "attempted to remove a poltergeist with no presence")- return- end-- local leave_presence = stanza.clone(original_presence)- leave_presence.attr.to = room.jid.."/"..nick- leave_presence.attr.from = component.."/"..nick- leave_presence.attr.type = "unavailable"-- if (ignore) then- set_ignored(room.jid.."/"..nick)- end-- remove_username(room, nick)- module:log("info", "removing poltergeist: %s/%s", room, nick)- room:handle_normal_presence(- prosody.hosts[component],- leave_presence- )-end---- Adds a poltergeist to a muc/room.--- @param room is the room the poltergeist will occupy--- @param is the id of the user the poltergeist represents--- @param display_name is the display name to use for the poltergeist--- @param avatar is the avatar link used for the poltergeist display--- @param context is the session context of the user making the request--- @param status is the presence status string to use--- @param resources is a table of resource types and resource ids to correlate.-local function add_to_muc(room, user_id, display_name, avatar, context, status, resources)- local username = uuid.generate()- local presence_stanza = original_presence(- room,- username,- display_name,- avatar,- context,- status- )-- module:log("info", "adding poltergeist: %s/%s", room, create_nick(username))- store_username(room, user_id, username)- for k, v in pairs(resources) do- add_call_resource(room, username, k, v)- end- room:handle_first_presence(- prosody.hosts[component],- presence_stanza- )-- local remove_delay = 5- local expiration = expiration_timeout - remove_delay;- local nick = create_nick(username)- timer.add_task(- expiration,- function ()- update(room, nick, "expired")- timer.add_task(- remove_delay,- function ()- if occupies(room, nick) then- remove(room, nick, false)- end- end- )- end- )-end---- Generates an original presence for a new poltergeist--- @param room is the room the poltergeist will occupy--- @param username is the unique name for the poltergeist--- @param display_name is the display name to use for the poltergeist--- @param avatar is the avatar link used for the poltergeist display--- @param context is the session context of the user making the request--- @param status is the presence status string to use--- @return a presence stanza that can be used to add the poltergeist to the muc-function original_presence(room, username, display_name, avatar, context, status)- local nick = create_nick(username)- local p = stanza.presence({- to = room.jid.."/"..nick,- from = component.."/"..nick,- }):tag("x", { xmlns = MUC_NS }):up();-- p:tag("bot", { type = "poltergeist" }):up();- p:tag("call_cancel"):text(nil):up();- p:tag("call_id"):text(username):up();-- if status then- p:tag("status"):text(status):up();- else- p:tag("status"):text(nil):up();- end-- if display_name then- p:tag(- "nick",- { xmlns = "http://jabber.org/protocol/nick" }):text(display_name):up();- end-- if avatar then- p:tag("avatar-url"):text(avatar):up();- end-- -- If the room has a password set, let the poltergeist enter using it- local room_password = room:get_password();- if room_password then- local join = p:get_child("x", MUC_NS);- join:tag("password", { xmlns = MUC_NS }):text(room_password);- end-- update_presence_identity(- p,- context.user,- context.group,- context.creator_user,- context.creator_group- )- return p-end--return {- get_username = get_username,- get_username_from_nick = get_username_from_nick,- occupies = occupies,- remove_room = remove_room,- reset_ignored = reset_ignored,- should_ignore = should_ignore,- create_nick = create_nick,- add_to_muc = add_to_muc,- update = update,- remove = remove-}diff --git a/tests/prosody/docker/prosody.cfg.lua b/tests/prosody/docker/prosody.cfg.luaindex 8a953ef812..db864ce8a8 100644--- a/tests/prosody/docker/prosody.cfg.lua+++ b/tests/prosody/docker/prosody.cfg.lua@@ -160,18 +160,6 @@ VirtualHost "shared-secret.localhost"VirtualHost "whitelist.localhost"authentication = "anonymous"--- VirtualHost for mod_turncredentials tests. Kept separate from the main--- VirtualHost because external_services (loaded by mod_turncredentials_http)--- hooks the same extdisco IQ event and would otherwise take precedence.-VirtualHost "turncredentials.localhost"- authentication = "anonymous"- modules_enabled = { "turncredentials" }- turncredentials_secret = "xmpp-turn-secret"- turncredentials = {- { type = "stun", host = "127.0.0.1", port = 3478 };- { type = "turn", host = "127.0.0.1", port = 3478 };- }-Component "lobby.conference.localhost" "muc"storage = "memory"muc_room_cache_size = 1000diff --git a/tests/prosody/mod_turncredentials_spec.js b/tests/prosody/mod_turncredentials_spec.jsdeleted file mode 100644index 74828c137a..0000000000--- a/tests/prosody/mod_turncredentials_spec.js+++ /dev/null@@ -1,32 +0,0 @@-import assert from 'assert';--import { createXmppClient } from './helpers/xmpp_client.js';-import { assertExtdiscoServices } from './helpers/xmpp_utils.js';--describe('mod_turncredentials', () => {-- const clients = [];-- afterEach(async () => {- await Promise.all(clients.map(c => c.disconnect()));- clients.length = 0;- });-- it('returns a result IQ with <services> to a c2s client', async () => {- const c = await createXmppClient({ domain: 'turncredentials.localhost' });-- clients.push(c);-- const iq = await c.sendExtdiscoIq('turncredentials.localhost');-- assert.equal(iq.attrs.type, 'result', `expected result IQ, got type="${iq.attrs.type}"`);-- const services = iq.getChild('services', 'urn:xmpp:extdisco:1');-- assert.ok(services, 'result IQ must contain <services xmlns="urn:xmpp:extdisco:1">');- });-- it('serves entries from turncredentials config (port 3478)', async () => {- await assertExtdiscoServices('turncredentials.localhost', 3478, clients);- });-});