mirror of
https://github.com/onionshare/onionshare.git
synced 2024-12-26 07:49:48 -05:00
Make the Web object load from mode settings instead of global settings
This commit is contained in:
parent
c426cfceb2
commit
12a1d73f91
@ -292,7 +292,7 @@ class ReceiveModeRequest(Request):
|
||||
date_dir = now.strftime("%Y-%m-%d")
|
||||
time_dir = now.strftime("%H.%M.%S")
|
||||
self.receive_mode_dir = os.path.join(
|
||||
self.web.common.settings.get("data_dir"), date_dir, time_dir
|
||||
self.web.settings.get("website", "data_dir"), date_dir, time_dir
|
||||
)
|
||||
|
||||
# Create that directory, which shouldn't exist yet
|
||||
|
@ -18,8 +18,8 @@ class ShareModeWeb(SendBaseModeWeb):
|
||||
self.common.log("ShareModeWeb", "init")
|
||||
|
||||
# Allow downloading individual files if "Stop sharing after files have been sent" is unchecked
|
||||
self.download_individual_files = not self.common.settings.get(
|
||||
"close_after_first_download"
|
||||
self.download_individual_files = not self.web.settings.get(
|
||||
"share", "autostop_sharing"
|
||||
)
|
||||
|
||||
def define_routes(self):
|
||||
|
@ -60,9 +60,7 @@ class Web:
|
||||
REQUEST_OTHER = 13
|
||||
REQUEST_INVALID_PASSWORD = 14
|
||||
|
||||
def __init__(
|
||||
self, common, is_gui, tab_settings_get=None, tab_settings_set=None, mode="share"
|
||||
):
|
||||
def __init__(self, common, is_gui, mode_settings, mode="share"):
|
||||
"""
|
||||
tab_settings_get and tab_settings_set are getter and setter functions for tab settings
|
||||
"""
|
||||
@ -70,8 +68,7 @@ class Web:
|
||||
self.common = common
|
||||
self.common.log("Web", "__init__", f"is_gui={is_gui}, mode={mode}")
|
||||
|
||||
self.settings_get = tab_settings_get
|
||||
self.settings_set = tab_settings_set
|
||||
self.settings = mode_settings
|
||||
|
||||
# The flask app
|
||||
self.app = Flask(
|
||||
@ -195,7 +192,7 @@ class Web:
|
||||
return None
|
||||
|
||||
# If public mode is disabled, require authentication
|
||||
if not self.common.settings.get("public_mode"):
|
||||
if not self.settings.get("general", "public"):
|
||||
|
||||
@self.auth.login_required
|
||||
def _check_login():
|
||||
@ -293,10 +290,7 @@ class Web:
|
||||
for header, value in self.security_headers:
|
||||
r.headers.set(header, value)
|
||||
# Set a CSP header unless in website mode and the user has disabled it
|
||||
if (
|
||||
not self.common.settings.get("csp_header_disabled")
|
||||
or self.mode != "website"
|
||||
):
|
||||
if not self.settings.get("website", "disable_csp") or self.mode != "website":
|
||||
r.headers.set(
|
||||
"Content-Security-Policy",
|
||||
"default-src 'self'; style-src 'self'; script-src 'self'; img-src 'self' data:;",
|
||||
|
@ -36,7 +36,7 @@ class ReceiveMode(Mode):
|
||||
Custom initialization for ReceiveMode.
|
||||
"""
|
||||
# Create the Web object
|
||||
self.web = Web(self.common, True, "receive")
|
||||
self.web = Web(self.common, True, self.settings, "receive")
|
||||
|
||||
# Header
|
||||
self.header_label.setText(strings._("gui_new_tab_receive_button"))
|
||||
|
@ -45,7 +45,7 @@ class ShareMode(Mode):
|
||||
self.compress_thread = None
|
||||
|
||||
# Create the Web object
|
||||
self.web = Web(self.common, True, "share")
|
||||
self.web = Web(self.common, True, self.settings, "share")
|
||||
|
||||
# Header
|
||||
self.header_label.setText(strings._("gui_new_tab_share_button"))
|
||||
|
@ -47,7 +47,7 @@ class WebsiteMode(Mode):
|
||||
Custom initialization for ReceiveMode.
|
||||
"""
|
||||
# Create the Web object
|
||||
self.web = Web(self.common, True, "website")
|
||||
self.web = Web(self.common, True, self.settings, "website")
|
||||
|
||||
# Header
|
||||
self.header_label.setText(strings._("gui_new_tab_website_button"))
|
||||
|
Loading…
Reference in New Issue
Block a user