|
|
@ -6,6 +6,7 @@ local parse = neturl.parseQuery; |
|
|
|
local st = require "util.stanza"; |
|
|
|
local st = require "util.stanza"; |
|
|
|
local get_room_from_jid = module:require "util".get_room_from_jid; |
|
|
|
local get_room_from_jid = module:require "util".get_room_from_jid; |
|
|
|
local wrap_async_run = module:require "util".wrap_async_run; |
|
|
|
local wrap_async_run = module:require "util".wrap_async_run; |
|
|
|
|
|
|
|
local update_presence_identity = module:require "util".update_presence_identity; |
|
|
|
local timer = require "util.timer"; |
|
|
|
local timer = require "util.timer"; |
|
|
|
local MUC_NS = "http://jabber.org/protocol/muc"; |
|
|
|
local MUC_NS = "http://jabber.org/protocol/muc"; |
|
|
|
|
|
|
|
|
|
|
@ -114,8 +115,9 @@ end |
|
|
|
-- @param token the token we received |
|
|
|
-- @param token the token we received |
|
|
|
-- @param room_name the room name |
|
|
|
-- @param room_name the room name |
|
|
|
-- @param group name of the group (optional) |
|
|
|
-- @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 |
|
|
|
-- @return true if values are ok or false otherwise |
|
|
|
function verify_token(token, room_name, group) |
|
|
|
function verify_token(token, room_name, group, session) |
|
|
|
if disableTokenVerification then |
|
|
|
if disableTokenVerification then |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
end |
|
|
|
end |
|
|
@ -129,7 +131,6 @@ function verify_token(token, room_name, group) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
local session = {}; |
|
|
|
|
|
|
|
session.auth_token = token; |
|
|
|
session.auth_token = token; |
|
|
|
local verified, reason = token_util:process_and_verify_token(session); |
|
|
|
local verified, reason = token_util:process_and_verify_token(session); |
|
|
|
if not verified then |
|
|
|
if not verified then |
|
|
@ -200,7 +201,8 @@ end); |
|
|
|
-- @param name the display name fot the occupant (optional) |
|
|
|
-- @param name the display name fot the occupant (optional) |
|
|
|
-- @param avatar the avatar to use for the new occupant (optional) |
|
|
|
-- @param avatar the avatar to use for the new occupant (optional) |
|
|
|
-- @param status the initial status to use for the new occupant (optional) |
|
|
|
-- @param status the initial status to use for the new occupant (optional) |
|
|
|
function create_poltergeist_occupant(room, nick, name, avatar, status) |
|
|
|
-- @param context the information that we will store for this poltergeist |
|
|
|
|
|
|
|
function create_poltergeist_occupant(room, nick, name, avatar, status, context) |
|
|
|
log("debug", "create_poltergeist_occupant %s", nick); |
|
|
|
log("debug", "create_poltergeist_occupant %s", nick); |
|
|
|
-- Join poltergeist occupant to room, with the invited JID as their nick |
|
|
|
-- Join poltergeist occupant to room, with the invited JID as their nick |
|
|
|
local join_presence = st.presence({ |
|
|
|
local join_presence = st.presence({ |
|
|
@ -227,6 +229,14 @@ function create_poltergeist_occupant(room, nick, name, avatar, status) |
|
|
|
join:tag("password", { xmlns = MUC_NS }):text(room_password); |
|
|
|
join:tag("password", { xmlns = MUC_NS }):text(room_password); |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
update_presence_identity( |
|
|
|
|
|
|
|
join_presence, |
|
|
|
|
|
|
|
context.user, |
|
|
|
|
|
|
|
context.group, |
|
|
|
|
|
|
|
context.creator_user, |
|
|
|
|
|
|
|
context.creator_group |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
room:handle_first_presence( |
|
|
|
room:handle_first_presence( |
|
|
|
prosody.hosts[poltergeist_component], join_presence); |
|
|
|
prosody.hosts[poltergeist_component], join_presence); |
|
|
|
|
|
|
|
|
|
|
@ -390,8 +400,9 @@ function handle_create_poltergeist (event) |
|
|
|
local name = params["name"]; |
|
|
|
local name = params["name"]; |
|
|
|
local avatar = params["avatar"]; |
|
|
|
local avatar = params["avatar"]; |
|
|
|
local status = params["status"]; |
|
|
|
local status = params["status"]; |
|
|
|
|
|
|
|
local session = {}; |
|
|
|
|
|
|
|
|
|
|
|
if not verify_token(params["token"], room_name, group) then |
|
|
|
if not verify_token(params["token"], room_name, group, session) then |
|
|
|
return 403; |
|
|
|
return 403; |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
@ -410,8 +421,16 @@ function handle_create_poltergeist (event) |
|
|
|
else |
|
|
|
else |
|
|
|
username = generate_uuid(); |
|
|
|
username = generate_uuid(); |
|
|
|
store_username(room, user_id, username); |
|
|
|
store_username(room, user_id, username); |
|
|
|
|
|
|
|
local context = { |
|
|
|
|
|
|
|
user = { |
|
|
|
|
|
|
|
id = user_id; |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
group = group; |
|
|
|
|
|
|
|
creator_user = session.jitsi_meet_context_user; |
|
|
|
|
|
|
|
creator_group = session.jitsi_meet_context_group; |
|
|
|
|
|
|
|
}; |
|
|
|
create_poltergeist_occupant( |
|
|
|
create_poltergeist_occupant( |
|
|
|
room, string.sub(username, 0, 8), name, avatar, status); |
|
|
|
room, string.sub(username, 0, 8), name, avatar, status, context); |
|
|
|
return 200; |
|
|
|
return 200; |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
@ -430,7 +449,7 @@ function handle_update_poltergeist (event) |
|
|
|
local group = params["group"]; |
|
|
|
local group = params["group"]; |
|
|
|
local status = params["status"]; |
|
|
|
local status = params["status"]; |
|
|
|
|
|
|
|
|
|
|
|
if not verify_token(params["token"], room_name, group) then |
|
|
|
if not verify_token(params["token"], room_name, group, {}) then |
|
|
|
return 403; |
|
|
|
return 403; |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
@ -467,7 +486,7 @@ function handle_remove_poltergeist (event) |
|
|
|
local room_name = params["room"]; |
|
|
|
local room_name = params["room"]; |
|
|
|
local group = params["group"]; |
|
|
|
local group = params["group"]; |
|
|
|
|
|
|
|
|
|
|
|
if not verify_token(params["token"], room_name, group) then |
|
|
|
if not verify_token(params["token"], room_name, group, {}) then |
|
|
|
return 403; |
|
|
|
return 403; |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|