Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
password_reset: Soft reactivate upon password reset.
Zixuan James Lif1ef27cb8574
diff --git a/docs/subsystems/sending-messages.md b/docs/subsystems/sending-messages.mdindex ff79f8ef1a9..94aa8107f88 100644--- a/docs/subsystems/sending-messages.md+++ b/docs/subsystems/sending-messages.md@@ -387,3 +387,9 @@ There are a few details that require special care with this system:determine what has happened in streams the user can see. We can usethe user's subscriptions to construct what messages they should haveaccess to for this feature.+- Soft-deactivated users experience high loading latency when+ returning after being idle for months. We optimize this by+ triggering a soft reactivation for users who receive email or push+ notification for private messages or personal mentions, or who+ request a password reset, since these are good leading indicators+ that a user is likely to return to Zulip.diff --git a/zerver/forms.py b/zerver/forms.pyindex 86e7917f822..335ec54aa39 100644--- a/zerver/forms.py+++ b/zerver/forms.py@@ -29,6 +29,7 @@ from zerver.lib.exceptions import JsonableError, RateLimitedfrom zerver.lib.name_restrictions import is_disposable_domain, is_reserved_subdomainfrom zerver.lib.rate_limiter import RateLimitedObjectfrom zerver.lib.send_email import FromAddress, send_email+from zerver.lib.soft_deactivation import queue_soft_reactivationfrom zerver.lib.subdomains import get_subdomain, is_root_domain_availablefrom zerver.lib.users import check_full_namefrom zerver.models import (@@ -360,6 +361,7 @@ class ZulipPasswordResetForm(PasswordResetForm):if user is not None:context["active_account_in_realm"] = Truecontext["reset_url"] = generate_password_reset_url(user, token_generator)+ queue_soft_reactivation(user.id)send_email("zerver/emails/password_reset",to_user_ids=[user.id],diff --git a/zerver/tests/test_signup.py b/zerver/tests/test_signup.pyindex 81076547073..96ebdba8e72 100644--- a/zerver/tests/test_signup.py+++ b/zerver/tests/test_signup.py@@ -731,6 +731,17 @@ class PasswordResetTest(ZulipTestCase):result = self.client_get("/accounts/new/send_confirm/[email protected]")self.assert_in_success_response(["/new/"], result)+ def test_password_reset_for_soft_deactivated_user(self) -> None:+ user_profile = self.example_user("hamlet")+ email = user_profile.delivery_email+ with self.soft_deactivate_and_check_long_term_idle(user_profile, False):+ # start the password reset process by supplying an email address+ result = self.client_post("/accounts/password/reset/", {"email": email})++ # check the redirect link telling you to check mail for password reset link+ self.assertEqual(result.status_code, 302)+ self.assertTrue(result["Location"].endswith("/accounts/password/reset/done/"))+class LoginTest(ZulipTestCase):"""