|
@@ -393,13 +393,19 @@ function handle_create_poltergeist (event)
|
393
|
393
|
return 404;
|
394
|
394
|
end
|
395
|
395
|
|
396
|
|
- local username = generate_uuid();
|
397
|
|
- store_username(room, user_id, username)
|
398
|
|
-
|
399
|
|
- create_poltergeist_occupant(
|
400
|
|
- room, string.sub(username,0,8), name, avatar, status);
|
401
|
|
-
|
402
|
|
- return 200;
|
|
396
|
+ local username = get_username(room, user_id);
|
|
397
|
+ if (username ~= nil
|
|
398
|
+ and have_poltergeist_occupant(room, string.sub(username, 0, 8))) then
|
|
399
|
+ log("warn", "poltergeist for username:%s already in the room:%s",
|
|
400
|
+ username, room_name);
|
|
401
|
+ return 202;
|
|
402
|
+ else
|
|
403
|
+ username = generate_uuid();
|
|
404
|
+ store_username(room, user_id, username);
|
|
405
|
+ create_poltergeist_occupant(
|
|
406
|
+ room, string.sub(username, 0, 8), name, avatar, status);
|
|
407
|
+ return 200;
|
|
408
|
+ end
|
403
|
409
|
end
|
404
|
410
|
|
405
|
411
|
--- Handles request for updating poltergeists status
|