From 1c949a5d71dbaa4db2bd0d8d6652364ca1636789 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Tue, 1 Nov 2022 18:08:45 -0700 Subject: [PATCH 1/3] Send confirmation emails directly, rather than with celery Whenver bookwyrm has an influx of new users, celery gets delayed and the emails don't get sent out promptly, which causes people to first resend the email multiple times, and then to email me, both of which just create more work and confusion for everyone involved. --- bookwyrm/emailing.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bookwyrm/emailing.py b/bookwyrm/emailing.py index 9349b8ae2..4a4557869 100644 --- a/bookwyrm/emailing.py +++ b/bookwyrm/emailing.py @@ -23,7 +23,7 @@ def email_confirmation_email(user): data = email_data() data["confirmation_code"] = user.confirmation_code data["confirmation_link"] = user.confirmation_link - send_email.delay(user.email, *format_email("confirm", data)) + send_email(user.email, *format_email("confirm", data)) def invite_email(invite_request): From 40ead411765d8507ef769f6d5bb0bcb273eb54c4 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Tue, 1 Nov 2022 18:17:37 -0700 Subject: [PATCH 2/3] Fixes rate limiter --- nginx/development | 2 +- nginx/production | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/nginx/development b/nginx/development index 4a7896249..be33cea17 100644 --- a/nginx/development +++ b/nginx/development @@ -7,7 +7,7 @@ upstream web { server { listen 80; - location ~ ^/(login[^-]|password-reset|resend-link|2fa-check) { + location ~ ^/(login[^-/]|password-reset|resend-link|2fa-check) { limit_req zone=loginlimit; proxy_pass http://web; diff --git a/nginx/production b/nginx/production index b74fe409c..949bc9340 100644 --- a/nginx/production +++ b/nginx/production @@ -41,7 +41,7 @@ server { # root /var/www/certbot; # } # -# location ~ ^/(login[^-]|password-reset|resend-link|2fa-check) { +# location ~ ^/(login[^-/]|password-reset|resend-link|2fa-check) { # limit_req zone=loginlimit; # # proxy_pass http://web; From 881d5682e387db880c0c69426d1cacaa1aa60369 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Tue, 1 Nov 2022 18:20:56 -0700 Subject: [PATCH 3/3] Updates test mock --- bookwyrm/tests/views/landing/test_register.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bookwyrm/tests/views/landing/test_register.py b/bookwyrm/tests/views/landing/test_register.py index aa1ca7fb9..0c14caed5 100644 --- a/bookwyrm/tests/views/landing/test_register.py +++ b/bookwyrm/tests/views/landing/test_register.py @@ -20,6 +20,7 @@ from bookwyrm.tests.validate_html import validate_html class RegisterViews(TestCase): """login and password management""" + # pylint: disable=invalid-name def setUp(self): """we need basic test data and mocks""" self.factory = RequestFactory() @@ -382,6 +383,6 @@ class RegisterViews(TestCase): """try again""" request = self.factory.post("", {"email": "mouse@mouse.com"}) request.user = self.anonymous_user - with patch("bookwyrm.emailing.send_email.delay") as mock: + with patch("bookwyrm.emailing.send_email") as mock: views.ResendConfirmEmail.as_view()(request) self.assertEqual(mock.call_count, 1)