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; return 404;
end end
local username = generate_uuid(); local username = get_username(room, user_id);
store_username(room, user_id, username) if (username ~= nil
and have_poltergeist_occupant(room, string.sub(username, 0, 8))) then
create_poltergeist_occupant( log("warn", "poltergeist for username:%s already in the room:%s",
room, string.sub(username,0,8), name, avatar, status); username, room_name);
return 202;
return 200; else
username = generate_uuid();
store_username(room, user_id, username);
create_poltergeist_occupant(
room, string.sub(username, 0, 8), name, avatar, status);
return 200;
end
end end
--- Handles request for updating poltergeists status --- Handles request for updating poltergeists status