aboutsummaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorMicah Lee <micah@micahflee.com>2021-04-11 21:16:18 -0700
committerMicah Lee <micah@micahflee.com>2021-04-11 21:16:18 -0700
commit91308bf51b90828611e0a951ba9362a101f1e1ff (patch)
tree53c7c36cc4468256a15345ada79d882c365d6b5b /desktop
parent84958ef7f3532859b9e861e7b7683d9a60fbcea6 (diff)
downloadonionshare-91308bf51b90828611e0a951ba9362a101f1e1ff.tar.gz
onionshare-91308bf51b90828611e0a951ba9362a101f1e1ff.zip
Add receive mode webhook to GUI
Diffstat (limited to 'desktop')
-rw-r--r--desktop/src/onionshare/resources/locale/en.json1
-rw-r--r--desktop/src/onionshare/tab/mode/receive_mode/__init__.py60
2 files changed, 60 insertions, 1 deletions
diff --git a/desktop/src/onionshare/resources/locale/en.json b/desktop/src/onionshare/resources/locale/en.json
index f7b8f7bb..74cac4ca 100644
--- a/desktop/src/onionshare/resources/locale/en.json
+++ b/desktop/src/onionshare/resources/locale/en.json
@@ -174,6 +174,7 @@
"mode_settings_share_autostop_sharing_checkbox": "Stop sharing after files have been sent (uncheck to allow downloading individual files)",
"mode_settings_receive_data_dir_label": "Save files to",
"mode_settings_receive_data_dir_browse_button": "Browse",
+ "mode_settings_receive_webhook_url_checkbox": "Use webhook URL",
"mode_settings_website_disable_csp_checkbox": "Don't send Content Security Policy header (allows your website to use third-party resources)",
"gui_all_modes_transfer_finished_range": "Transferred {} - {}",
"gui_all_modes_transfer_finished": "Transferred {}",
diff --git a/desktop/src/onionshare/tab/mode/receive_mode/__init__.py b/desktop/src/onionshare/tab/mode/receive_mode/__init__.py
index 8a848128..5f65152e 100644
--- a/desktop/src/onionshare/tab/mode/receive_mode/__init__.py
+++ b/desktop/src/onionshare/tab/mode/receive_mode/__init__.py
@@ -60,6 +60,8 @@ class ReceiveMode(Mode):
self.image.setLayout(image_layout)
# Settings
+
+ # Data dir
data_dir_label = QtWidgets.QLabel(
strings._("mode_settings_receive_data_dir_label")
)
@@ -74,9 +76,36 @@ class ReceiveMode(Mode):
data_dir_layout.addWidget(data_dir_label)
data_dir_layout.addWidget(self.data_dir_lineedit)
data_dir_layout.addWidget(data_dir_button)
-
self.mode_settings_widget.mode_specific_layout.addLayout(data_dir_layout)
+ # Webhook URL
+ webhook_url = self.settings.get("receive", "webhook_url")
+ self.webhook_url_checkbox = QtWidgets.QCheckBox()
+ self.webhook_url_checkbox.clicked.connect(self.webhook_url_checkbox_clicked)
+ self.webhook_url_checkbox.setText(
+ strings._("mode_settings_receive_webhook_url_checkbox")
+ )
+ self.webhook_url_lineedit = QtWidgets.QLineEdit()
+ self.webhook_url_lineedit.editingFinished.connect(
+ self.webhook_url_editing_finished
+ )
+ self.webhook_url_lineedit.setPlaceholderText(
+ "https://example.com/post-when-file-uploaded"
+ )
+ webhook_url_layout = QtWidgets.QHBoxLayout()
+ webhook_url_layout.addWidget(self.webhook_url_checkbox)
+ webhook_url_layout.addWidget(self.webhook_url_lineedit)
+ if webhook_url is not None and webhook_url != "":
+ self.webhook_url_checkbox.setCheckState(QtCore.Qt.Checked)
+ self.webhook_url_lineedit.setText(
+ self.settings.get("receive", "webhook_url")
+ )
+ self.show_webhook_url()
+ else:
+ self.webhook_url_checkbox.setCheckState(QtCore.Qt.Unchecked)
+ self.hide_webhook_url()
+ self.mode_settings_widget.mode_specific_layout.addLayout(webhook_url_layout)
+
# Server status
self.server_status.set_mode("receive")
self.server_status.server_started_finished.connect(self.update_primary_action)
@@ -183,6 +212,25 @@ class ReceiveMode(Mode):
self.data_dir_lineedit.setText(selected_dir)
self.settings.set("receive", "data_dir", selected_dir)
+ def webhook_url_checkbox_clicked(self):
+ if self.webhook_url_checkbox.isChecked():
+ if self.settings.get("receive", "webhook_url"):
+ self.webhook_url_lineedit.setText(
+ self.settings.get("receive", "webhook_url")
+ )
+ self.show_webhook_url()
+ else:
+ self.hide_webhook_url()
+
+ def webhook_url_editing_finished(self):
+ self.settings.set("receive", "webhook_url", self.webhook_url_lineedit.text())
+
+ def hide_webhook_url(self):
+ self.webhook_url_lineedit.hide()
+
+ def show_webhook_url(self):
+ self.webhook_url_lineedit.show()
+
def get_stop_server_autostop_timer_text(self):
"""
Return the string to put on the stop server button, if there's an auto-stop timer
@@ -220,6 +268,16 @@ class ReceiveMode(Mode):
# Hide and reset the uploads if we have previously shared
self.reset_info_counters()
+ # Set proxies for webhook URL
+ if self.common.gui.local_only:
+ self.web.proxies = None
+ else:
+ (socks_address, socks_port) = self.common.gui.onion.get_tor_socks_port()
+ self.web.proxies = {
+ "http": f"socks5://{socks_address}:{socks_port}",
+ "https": f"socks5://{socks_address}:{socks_port}",
+ }
+
def start_server_step2_custom(self):
"""
Step 2 in starting the server.