mirror of
https://github.com/onionshare/onionshare.git
synced 2024-10-01 01:35:40 -04:00
Merge branch 'main' of github.com:onionshare/onionshare-ghsa-wh24-f3hg-r3h2 into release-2.6.2
This commit is contained in:
commit
d5c25527ac
@ -114,7 +114,11 @@ class ChatModeWeb:
|
||||
title=self.web.settings.get("general", "title"),
|
||||
)
|
||||
|
||||
@self.web.app.route("/update-session-username", methods=["POST"], provide_automatic_options=False)
|
||||
@self.web.app.route(
|
||||
"/update-session-username",
|
||||
methods=["POST"],
|
||||
provide_automatic_options=False,
|
||||
)
|
||||
def update_session_username():
|
||||
history_id = self.cur_history_id
|
||||
data = request.get_json()
|
||||
@ -153,6 +157,8 @@ class ChatModeWeb:
|
||||
A status message is broadcast to all people in the room."""
|
||||
if self.validate_username(session.get("name")):
|
||||
self.connected_users.append(session.get("name"))
|
||||
# Store the session id for the user
|
||||
session["socketio_session_id"] = request.sid
|
||||
emit(
|
||||
"status",
|
||||
{
|
||||
@ -184,9 +190,9 @@ class ChatModeWeb:
|
||||
new_name = message.get("username", "").strip()
|
||||
if self.validate_username(new_name):
|
||||
session["name"] = new_name
|
||||
self.connected_users[
|
||||
self.connected_users.index(current_name)
|
||||
] = session.get("name")
|
||||
self.connected_users[self.connected_users.index(current_name)] = (
|
||||
session.get("name")
|
||||
)
|
||||
emit(
|
||||
"status",
|
||||
{
|
||||
@ -209,8 +215,18 @@ class ChatModeWeb:
|
||||
def disconnect():
|
||||
"""Sent by clients when they disconnect.
|
||||
A status message is broadcast to all people in the server."""
|
||||
user_already_disconnected = False
|
||||
if session.get("name") in self.connected_users:
|
||||
self.connected_users.remove(session.get("name"))
|
||||
else:
|
||||
user_already_disconnected = True
|
||||
|
||||
# Forcefully disconnect the user
|
||||
self.web.socketio.server.disconnect(
|
||||
sid=session.get("socketio_session_id"), namespace="/chat"
|
||||
)
|
||||
|
||||
if not user_already_disconnected:
|
||||
emit(
|
||||
"status",
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user