diff --git a/resources/prosody-plugins/mod_muc_poltergeist.lua b/resources/prosody-plugins/mod_muc_poltergeist.lua index 8e59d0c4a..0b18eee27 100644 --- a/resources/prosody-plugins/mod_muc_poltergeist.lua +++ b/resources/prosody-plugins/mod_muc_poltergeist.lua @@ -393,13 +393,19 @@ function handle_create_poltergeist (event) return 404; end - local username = generate_uuid(); - store_username(room, user_id, username) - - create_poltergeist_occupant( - room, string.sub(username,0,8), name, avatar, status); - - return 200; + 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); + return 200; + end end --- Handles request for updating poltergeists status