Move the 'supports_file_requests' attribute into the actual modes rather than the Web class

This commit is contained in:
Miguel Jacq 2021-05-11 09:25:22 +10:00
parent 3394571fad
commit d4d6eea500
No known key found for this signature in database
GPG Key ID: EEA4341C6D97A0B6
4 changed files with 20 additions and 7 deletions

View File

@ -39,6 +39,12 @@ class ChatModeWeb:
# This tracks the history id
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()
def define_routes(self):

View File

@ -64,6 +64,10 @@ class ReceiveModeWeb:
# This tracks the history id
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
self.supports_file_requests = True
self.define_routes()
def define_routes(self):

View File

@ -52,6 +52,10 @@ class SendBaseModeWeb:
# This tracks the history id
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
self.supports_file_requests = True
self.define_routes()
self.init()

View File

@ -152,7 +152,6 @@ class Web:
self.receive_mode = None
self.website_mode = None
self.chat_mode = None
self.mode_supports_file_requests = True
if self.mode == "share":
self.share_mode = ShareModeWeb(self.common, self)
elif self.mode == "receive":
@ -163,9 +162,6 @@ class Web:
self.socketio = SocketIO()
self.socketio.init_app(self.app)
self.chat_mode = ChatModeWeb(self.common, self)
# Chat mode has no concept of individual file requests that
# turn into history widgets in the GUI
self.mode_supports_file_requests = False
self.cleanup_filenames = []
@ -298,7 +294,8 @@ class Web:
return self.add_security_headers(r)
def error404(self, history_id):
if self.mode_supports_file_requests:
mode = self.get_mode()
if mode.supports_file_requests:
self.add_request(
self.REQUEST_INDIVIDUAL_FILE_STARTED,
request.path,
@ -312,7 +309,8 @@ class Web:
return self.add_security_headers(r)
def error405(self, history_id):
if self.mode_supports_file_requests:
mode = self.get_mode()
if mode.supports_file_requests:
self.add_request(
self.REQUEST_INDIVIDUAL_FILE_STARTED,
request.path,
@ -326,7 +324,8 @@ class Web:
return self.add_security_headers(r)
def error500(self, history_id):
if self.mode_supports_file_requests:
mode = self.get_mode()
if mode.supports_file_requests:
self.add_request(
self.REQUEST_INDIVIDUAL_FILE_STARTED,
request.path,