Adds initial status param when creating poltergeist.

This commit is contained in:
damencho 2017-07-20 13:29:54 -05:00
parent f40faecfbe
commit 284b5f94b5
1 changed files with 8 additions and 2 deletions

View File

@ -134,7 +134,8 @@ end);
-- @param nick the nick to use for the new occupant
-- @param name the display name fot the occupant (optional)
-- @param avatar the avatar to use for the new occupant (optional)
function create_poltergeist_occupant(room, nick, name, avatar)
-- @param status the initial status to use for the new occupant (optional)
function create_poltergeist_occupant(room, nick, name, avatar, status)
log("debug", "create_poltergeist_occupant %s:", nick);
-- Join poltergeist occupant to room, with the invited JID as their nick
local join_presence = st.presence({
@ -150,6 +151,9 @@ function create_poltergeist_occupant(room, nick, name, avatar)
if (avatar) then
join_presence:tag("avatar-url"):text(avatar):up();
end
if (status) then
join_presence:tag("status"):text(status):up();
end
room:handle_first_presence(
prosody.hosts[poltergeist_component], join_presence);
@ -247,6 +251,7 @@ function handle_create_poltergeist (event)
local group = params["group"];
local name = params["name"];
local avatar = params["avatar"];
local status = params["status"];
local room = get_room(room_name, group);
if (not room) then
@ -257,7 +262,8 @@ function handle_create_poltergeist (event)
local username = generate_uuid();
store_username(room, user_id, username)
create_poltergeist_occupant(room, string.sub(username,0,8), name, avatar);
create_poltergeist_occupant(
room, string.sub(username,0,8), name, avatar, status);
return 200;
end