Ver código fonte

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

j8
Дамян Минков 8 anos atrás
pai
commit
5b6d7a3040
1 arquivos alterados com 13 adições e 7 exclusões
  1. 13
    7
      resources/prosody-plugins/mod_muc_poltergeist.lua

+ 13
- 7
resources/prosody-plugins/mod_muc_poltergeist.lua Ver arquivo

@@ -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

Carregando…
Cancelar
Salvar