summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiguel Jacq <mig@mig5.net>2021-05-11 09:25:22 +1000
committerMiguel Jacq <mig@mig5.net>2021-05-11 09:25:22 +1000
commitd4d6eea500feb825d5639354b8aad1be6ba451f5 (patch)
tree825ca3140635d0cb7e0280a511a5d7b913b83575
parent3394571fadcb4c6b20d1c7255d99dc668f06c58d (diff)
downloadonionshare-d4d6eea500feb825d5639354b8aad1be6ba451f5.tar.gz
onionshare-d4d6eea500feb825d5639354b8aad1be6ba451f5.zip
Move the 'supports_file_requests' attribute into the actual modes rather than the Web class
-rw-r--r--cli/onionshare_cli/web/chat_mode.py6
-rw-r--r--cli/onionshare_cli/web/receive_mode.py4
-rw-r--r--cli/onionshare_cli/web/send_base_mode.py4
-rw-r--r--cli/onionshare_cli/web/web.py13
4 files changed, 20 insertions, 7 deletions
diff --git a/cli/onionshare_cli/web/chat_mode.py b/cli/onionshare_cli/web/chat_mode.py
index 385972fe..91c41d2f 100644
--- a/cli/onionshare_cli/web/chat_mode.py
+++ b/cli/onionshare_cli/web/chat_mode.py
@@ -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):
diff --git a/cli/onionshare_cli/web/receive_mode.py b/cli/onionshare_cli/web/receive_mode.py
index b3a146e3..76abb0a8 100644
--- a/cli/onionshare_cli/web/receive_mode.py
+++ b/cli/onionshare_cli/web/receive_mode.py
@@ -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):
diff --git a/cli/onionshare_cli/web/send_base_mode.py b/cli/onionshare_cli/web/send_base_mode.py
index 2f3e0bbd..e448d2dd 100644
--- a/cli/onionshare_cli/web/send_base_mode.py
+++ b/cli/onionshare_cli/web/send_base_mode.py
@@ -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()
diff --git a/cli/onionshare_cli/web/web.py b/cli/onionshare_cli/web/web.py
index b947b491..56e307b4 100644
--- a/cli/onionshare_cli/web/web.py
+++ b/cli/onionshare_cli/web/web.py
@@ -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,