mirror of
https://github.com/onionshare/onionshare.git
synced 2025-05-03 15:05:11 -04:00
resolve conflict in chat_mode.py
This commit is contained in:
parent
2d79bcdfcc
commit
da1e6eb866
1 changed files with 38 additions and 12 deletions
|
@ -39,6 +39,12 @@ class ChatModeWeb:
|
||||||
# This tracks the history id
|
# This tracks the history id
|
||||||
self.cur_history_id = 0
|
self.cur_history_id = 0
|
||||||
|
|
||||||
|
# Whether or not we can send REQUEST_INDIVIDUAL_FILE_STARTED
|
||||||
|
# and maybe other events when requests come in to this mode
|
||||||
|
# Chat mode has no concept of individual file requests that
|
||||||
|
# turn into history widgets in the GUI, so set it to False
|
||||||
|
self.supports_file_requests = False
|
||||||
|
|
||||||
self.define_routes()
|
self.define_routes()
|
||||||
|
|
||||||
def define_routes(self):
|
def define_routes(self):
|
||||||
|
@ -46,7 +52,7 @@ class ChatModeWeb:
|
||||||
The web app routes for chatting
|
The web app routes for chatting
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@self.web.app.route("/")
|
@self.web.app.route("/", methods=["GET"], provide_automatic_options=False)
|
||||||
def index():
|
def index():
|
||||||
history_id = self.cur_history_id
|
history_id = self.cur_history_id
|
||||||
self.cur_history_id += 1
|
self.cur_history_id += 1
|
||||||
|
@ -66,16 +72,18 @@ class ChatModeWeb:
|
||||||
"chat.html",
|
"chat.html",
|
||||||
static_url_path=self.web.static_url_path,
|
static_url_path=self.web.static_url_path,
|
||||||
username=session.get("name"),
|
username=session.get("name"),
|
||||||
title=self.web.settings.get("general", "title")
|
title=self.web.settings.get("general", "title"),
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@self.web.app.route("/update-session-username", methods=["POST"])
|
@self.web.app.route("/update-session-username", methods=["POST"], provide_automatic_options=False)
|
||||||
def update_session_username():
|
def update_session_username():
|
||||||
history_id = self.cur_history_id
|
history_id = self.cur_history_id
|
||||||
data = request.get_json()
|
data = request.get_json()
|
||||||
if (
|
if (
|
||||||
data.get("username", "")
|
data.get("username", "")
|
||||||
and data.get("username", "") not in self.connected_users
|
and data.get("username", "") not in self.connected_users
|
||||||
|
and len(data.get("username", "")) < 128
|
||||||
):
|
):
|
||||||
session["name"] = data.get("username", session.get("name"))
|
session["name"] = data.get("username", session.get("name"))
|
||||||
self.web.add_request(
|
self.web.add_request(
|
||||||
|
@ -84,7 +92,25 @@ class ChatModeWeb:
|
||||||
)
|
)
|
||||||
|
|
||||||
self.web.add_request(self.web.REQUEST_LOAD, request.path)
|
self.web.add_request(self.web.REQUEST_LOAD, request.path)
|
||||||
return jsonify(username=session.get("name"), success=True)
|
r = make_response(
|
||||||
|
jsonify(
|
||||||
|
username=session.get("name"),
|
||||||
|
success=True,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
self.web.add_request(
|
||||||
|
request.path,
|
||||||
|
{"id": history_id, "status_code": 403},
|
||||||
|
)
|
||||||
|
|
||||||
|
r = make_response(
|
||||||
|
jsonify(
|
||||||
|
username=session.get("name"),
|
||||||
|
success=False,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
return r
|
||||||
|
|
||||||
@self.web.socketio.on("joined", namespace="/chat")
|
@self.web.socketio.on("joined", namespace="/chat")
|
||||||
def joined(message):
|
def joined(message):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue