Update app.py
Browse files
app.py
CHANGED
@@ -588,24 +588,27 @@ def join_chat_room(room_id):
|
|
588 |
if room["settings"]["password"] and password != room["settings"]["password"]:
|
589 |
return jsonify({"error": "Wrong password"}), 403
|
590 |
|
591 |
-
#
|
592 |
-
if admin_session == room["admin_session"]:
|
|
|
593 |
role = "admin"
|
594 |
session_id = admin_session
|
|
|
595 |
else:
|
596 |
-
#
|
597 |
active_receivers = sum(1 for s in room["active_sessions"].values() if s["role"] == "receiver")
|
598 |
if active_receivers >= room["settings"]["max_receivers"]:
|
599 |
return jsonify({"error": "Chat room is full"}), 403
|
600 |
|
601 |
-
role = "receiver"
|
602 |
session_id = str(uuid.uuid4())
|
603 |
room["receiver_counter"] += 1
|
|
|
604 |
|
605 |
return jsonify({
|
606 |
"session_id": session_id,
|
607 |
"role": role,
|
608 |
-
"receiver_number":
|
609 |
"room_settings": room["settings"],
|
610 |
"expires_at": room["expires_at"]
|
611 |
})
|
|
|
588 |
if room["settings"]["password"] and password != room["settings"]["password"]:
|
589 |
return jsonify({"error": "Wrong password"}), 403
|
590 |
|
591 |
+
# FIXED: Proper role assignment
|
592 |
+
if admin_session and admin_session == room["admin_session"]:
|
593 |
+
# Only admin if the session matches the room's admin session
|
594 |
role = "admin"
|
595 |
session_id = admin_session
|
596 |
+
receiver_number = None
|
597 |
else:
|
598 |
+
# Everyone else is a receiver
|
599 |
active_receivers = sum(1 for s in room["active_sessions"].values() if s["role"] == "receiver")
|
600 |
if active_receivers >= room["settings"]["max_receivers"]:
|
601 |
return jsonify({"error": "Chat room is full"}), 403
|
602 |
|
603 |
+
role = "receiver"
|
604 |
session_id = str(uuid.uuid4())
|
605 |
room["receiver_counter"] += 1
|
606 |
+
receiver_number = room["receiver_counter"]
|
607 |
|
608 |
return jsonify({
|
609 |
"session_id": session_id,
|
610 |
"role": role,
|
611 |
+
"receiver_number": receiver_number,
|
612 |
"room_settings": room["settings"],
|
613 |
"expires_at": room["expires_at"]
|
614 |
})
|