Skips creating duplicate poltergeists for the same user. (#1925)

This commit is contained in:
Дамян Минков 2017-08-23 16:14:44 -05:00 committed by Aaron van Meerten
parent 1ca485f1a8
commit 5b6d7a3040
1 changed files with 13 additions and 7 deletions

View File

@ -393,13 +393,19 @@ function handle_create_poltergeist (event)
return 404;
end
local username = generate_uuid();
store_username(room, user_id, username)
local username = get_username(room, user_id);
if (username ~= nil
and have_poltergeist_occupant(room, string.sub(username, 0, 8))) then
log("warn", "poltergeist for username:%s already in the room:%s",
username, room_name);
return 202;
else
username = generate_uuid();
store_username(room, user_id, username);
create_poltergeist_occupant(
room, string.sub(username,0,8), name, avatar, status);
room, string.sub(username, 0, 8), name, avatar, status);
return 200;
end
end
--- Handles request for updating poltergeists status