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
Properly propagating call id for call response handling.
Jacob MacElroye36749083956
diff --git a/resources/prosody-plugins/mod_muc_call.lua b/resources/prosody-plugins/mod_muc_call.luaindex ec3d026a91..b5f8ea7a02 100644--- a/resources/prosody-plugins/mod_muc_call.lua+++ b/resources/prosody-plugins/mod_muc_call.lua@@ -67,17 +67,29 @@ module:hook("muc-broadcast-presence", function (event)returnend- local invite = function()- local url = assert(url_from_room_jid(event.stanza.attr.from))- ext_events.invite(event.stanza, url)+ 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))+ ext_events.invite(event.stanza, url, call_id)end- local cancel = function()+ local cancel = function()local url = assert(url_from_room_jid(event.stanza.attr.from))local status = event.stanza:get_child_text("status")- ext_events.cancel(event.stanza, url, string.lower(status))+ ext_events.cancel(event.stanza, url, string.lower(status), call_id)end+ local should_cancel = event.stanza:get_child_text("call_cancel")+ if should_cancel == "true" then+ cancel()+ return+ end+local switch = function(status)case = {[calling_status] = function() invite() end,diff --git a/resources/prosody-plugins/mod_muc_poltergeist.lua b/resources/prosody-plugins/mod_muc_poltergeist.luaindex 94712b3c20..464bb9b604 100644--- a/resources/prosody-plugins/mod_muc_poltergeist.lua+++ b/resources/prosody-plugins/mod_muc_poltergeist.lua@@ -108,6 +108,27 @@ function remove_username(room, nick)endend+-- Provides a new presence stanza for a poltergeist.+-- @param room the room instance+-- @param nick the user nick+function generate_poltergeist_presence(room, nick, status)+ local presence_stanza = st.presence({+ to = room.jid.."/"..nick,+ from = poltergeist_component.."/"..nick,+ }):tag("x", { xmlns = MUC_NS }):up();++ presence_stanza:tag("call_cancel"):text(nil):up();+ presence_stanza:tag("call_id"):text(nil):up();++ if status then+ presence_stanza:tag("status"):text(status):up();+ else+ presence_stanza:tag("status"):text(nil):up();+ end++ return presence_stanza;+end+--- Verifies room name, domain name with the values in the token-- @param token the token we received-- @param room_name the room name@@ -182,7 +203,7 @@ prosody.events.add_handler("pre-jitsi-authentication", function(session)if (have_poltergeist_occupant(room, nick)) then-- notify that user connected using the poltergeistupdate_poltergeist_occupant_status(- room, nick, "connected");+ room, nick, "connected");remove_poltergeist_occupant(room, nick, true);end@@ -202,10 +223,7 @@ end);function create_poltergeist_occupant(room, nick, name, avatar, status, context)log("debug", "create_poltergeist_occupant %s", nick);-- Join poltergeist occupant to room, with the invited JID as their nick- local join_presence = st.presence({- to = room.jid.."/"..nick,- from = poltergeist_component.."/"..nick- }):tag("x", { xmlns = MUC_NS }):up();+ local join_presence = generate_poltergeist_presence(room, nick, status)if (name) thenjoin_presence:tag(@@ -215,9 +233,6 @@ function create_poltergeist_occupant(room, nick, name, avatar, status, context)if (avatar) thenjoin_presence:tag("avatar-url"):text(avatar):up();end- if (status) then- join_presence:tag("status"):text(status):up();- end-- If the room has a password set, let the poltergeist enter using itlocal room_password = room:get_password();@@ -226,6 +241,9 @@ function create_poltergeist_occupant(room, nick, name, avatar, status, context)join:tag("password", { xmlns = MUC_NS }):text(room_password);end+ local call_id = get_username(room, context.user.id);+ join_presence:tag("call_id"):text(get_username(room, context.user.id)):up();+update_presence_identity(join_presence,context.user,@@ -278,15 +296,13 @@ end-- @param room the room instance where to remove the occupant-- @param nick the nick of the occupant to remove-- @param status the status to update-function update_poltergeist_occupant_status(room, nick, status)+-- @param call_details is a table of call flow details+function update_poltergeist_occupant_status(room, nick, status, call_details)local update_presence = get_presence(room, nick);if (not update_presence) then-- no presence found for occupant, create one- update_presence = st.presence({- to = room.jid.."/"..nick,- from = poltergeist_component.."/"..nick- });+ update_presence = generate_poltergeist_presence(room, nick)else-- update occupant presence with appropriate to and from-- so we can send it again@@ -295,29 +311,54 @@ function update_poltergeist_occupant_status(room, nick, status)update_presence.attr.from = poltergeist_component.."/"..nick;end- local once = false;- -- the status tag we will attach- local statusTag = st.stanza("status"):text(status);+ update_presence = update_presence_tags(update_presence, status, call_details)- -- if there is already a status tag replace it- update_presence:maptags(function (tag)- if tag.name == statusTag.name then- if not once then- once = true;- return statusTag;+ room:handle_normal_presence(+ prosody.hosts[poltergeist_component], update_presence);+end++-- Updates the status tags and call flow tags of an existing poltergeist's+-- 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 st.stanza("status"):text(status);+ elseif tag.name == "call_id" then+ if call_id then+ return st.stanza("call_id"):text(call_id);else- return nil;+ -- 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 st.stanza("call_cancel"):text("true");+ else+ return st.stanza("call_cancel"):text("false");endend- return tag;end);- if (not once) then- -- no status tag was repleced, attach it- update_presence:add_child(statusTag);- end- room:handle_normal_presence(- prosody.hosts[poltergeist_component], update_presence);+ return presence_stanzaend-- Checks for existance of a poltergeist occupant@@ -436,6 +477,12 @@ function handle_update_poltergeist (event)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;+ endif not verify_token(params["token"], room_name, group, {}) thenreturn 403;@@ -452,9 +499,14 @@ function handle_update_poltergeist (event)return 404;end+ local call_details = {+ ["cancel"] = call_cancel;+ ["id"] = call_id;+ };+local nick = string.sub(username, 0, 8);if (have_poltergeist_occupant(room, nick)) then- update_poltergeist_occupant_status(room, nick, status);+ update_poltergeist_occupant_status(room, nick, status, call_details);return 200;elsereturn 404;