From f5babd9c81bd900a798d875aacdf0ee797d4377a Mon Sep 17 00:00:00 2001 From: Son Nguyen Kim Date: Thu, 14 Mar 2024 15:56:35 +0100 Subject: [PATCH] Move import export back to setting (#2063) * replace black by ruff * move alias import/export to settings * fix html closing tag * add rate limit for alias import & export --------- Co-authored-by: Son NK --- CONTRIBUTING.md | 4 ++-- app/dashboard/views/alias_export.py | 2 ++ app/dashboard/views/batch_import.py | 4 +++- templates/dashboard/account_setting.html | 15 --------------- templates/dashboard/setting.html | 19 ++++++++++++++++++- 5 files changed, 25 insertions(+), 19 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 637d2fdb..b6b1019f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -151,10 +151,10 @@ Here are the small sum-ups of the directory structures and their roles: ## Pull request -The code is formatted using https://github.com/psf/black, to format the code, simply run +The code is formatted using [ruff](https://github.com/astral-sh/ruff), to format the code, simply run ``` -poetry run black . +poetry run ruff format . ``` The code is also checked with `flake8`, make sure to run `flake8` before creating the pull request by diff --git a/app/dashboard/views/alias_export.py b/app/dashboard/views/alias_export.py index f21df4b7..159b00d2 100644 --- a/app/dashboard/views/alias_export.py +++ b/app/dashboard/views/alias_export.py @@ -2,10 +2,12 @@ from app.dashboard.base import dashboard_bp from flask_login import login_required, current_user from app.alias_utils import alias_export_csv from app.dashboard.views.enter_sudo import sudo_required +from app.extensions import limiter @dashboard_bp.route("/alias_export", methods=["GET"]) @login_required @sudo_required +@limiter.limit("2/minute") def alias_export_route(): return alias_export_csv(current_user) diff --git a/app/dashboard/views/batch_import.py b/app/dashboard/views/batch_import.py index 7521cc09..3adf335e 100644 --- a/app/dashboard/views/batch_import.py +++ b/app/dashboard/views/batch_import.py @@ -7,6 +7,7 @@ from app.config import JOB_BATCH_IMPORT from app.dashboard.base import dashboard_bp from app.dashboard.views.enter_sudo import sudo_required from app.db import Session +from app.extensions import limiter from app.log import LOG from app.models import File, BatchImport, Job from app.utils import random_string, CSRFValidationForm @@ -15,6 +16,7 @@ from app.utils import random_string, CSRFValidationForm @dashboard_bp.route("/batch_import", methods=["GET", "POST"]) @login_required @sudo_required +@limiter.limit("10/minute", methods=["POST"]) def batch_import_route(): # only for users who have custom domains if not current_user.verified_custom_domains(): @@ -39,7 +41,7 @@ def batch_import_route(): return redirect(request.url) if len(batch_imports) > 10: flash( - "You have too many imports already. Wait until some get cleaned up", + "You have too many imports already. Please wait until some get cleaned up", "error", ) return render_template( diff --git a/templates/dashboard/account_setting.html b/templates/dashboard/account_setting.html index a6ba0b51..58ad7cef 100644 --- a/templates/dashboard/account_setting.html +++ b/templates/dashboard/account_setting.html @@ -120,21 +120,6 @@ - -
-
-
Alias import/export
-
- You can import your aliases created on other platforms into SimpleLogin. - You can also export your aliases to a readable csv format for a future batch import. -
- Batch Import - Export Aliases -
-
-
diff --git a/templates/dashboard/setting.html b/templates/dashboard/setting.html index e3e7b17a..03403766 100644 --- a/templates/dashboard/setting.html +++ b/templates/dashboard/setting.html @@ -559,7 +559,7 @@ sender address.
If this option is enabled, the original sender addresses is stored in the email header X-SimpleLogin-Envelope-From - and the original From header is stored in X-SimpleLogin-Original-From. + and the original From header is stored in X-SimpleLogin-Original-From. You can choose to display this header in your email client.
As email headers aren't encrypted, your mailbox service can know the sender address via this header. @@ -583,6 +583,23 @@
+ +
+
+
+ Alias import/export +
+
+ You can import your aliases created on other platforms into SimpleLogin. + You can also export your aliases to a readable csv format for a future batch import. +
+ Batch Import + Export Aliases +
+
+ {% endblock %} {% block script %}