From 839b23f87a367a60f25f4f2979611547e6590b90 Mon Sep 17 00:00:00 2001 From: Micah Lee Date: Mon, 12 Apr 2021 09:08:47 -0700 Subject: [PATCH] Improve webhook label in GUI, improve webhook message that gets POSTed, and display webhook errors without verbose mode --- cli/onionshare_cli/web/receive_mode.py | 12 ++++++------ desktop/src/onionshare/resources/locale/en.json | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cli/onionshare_cli/web/receive_mode.py b/cli/onionshare_cli/web/receive_mode.py index 26ec0b65..46f471a8 100644 --- a/cli/onionshare_cli/web/receive_mode.py +++ b/cli/onionshare_cli/web/receive_mode.py @@ -108,7 +108,11 @@ class ReceiveModeWeb: and not request.upload_error and len(files) > 0 ): - self.send_webhook_notification(f"{len(files)} files uploaded") + if len(files) == 1: + file_msg = "1 file" + else: + file_msg = f"{len(files)} files" + self.send_webhook_notification(f"{file_msg} uploaded to OnionShare") if request.upload_error: self.common.log( @@ -191,11 +195,7 @@ class ReceiveModeWeb: proxies=self.web.proxies, ) except Exception as e: - self.common.log( - "ReceiveModeWeb", - "send_webhook_notification", - f"sending failed: {e}", - ) + print(f"Webhook notification failed: {e}") class ReceiveModeWSGIMiddleware(object): diff --git a/desktop/src/onionshare/resources/locale/en.json b/desktop/src/onionshare/resources/locale/en.json index 74cac4ca..20569c57 100644 --- a/desktop/src/onionshare/resources/locale/en.json +++ b/desktop/src/onionshare/resources/locale/en.json @@ -174,7 +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_receive_webhook_url_checkbox": "Use notification webhook", "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 {}",