Repository: zulip/zulip

Issue:
Add organization details to new organization sign-up confirmation email
Following up on https://github.com/zulip/zulip/issues/24307 / https://github.com/zulip/zulip/pull/24689, we should add organization information to the `confirm_registration` email.

Current text:
    {{ _('You have requested a new Zulip organization. Awesome!') }}
    {{ _('Click the button below to create the organization and register your account.') }}

Updated text (with appropriate translation tags):

---
You have requested a new Zulip organization:

- Organization URL:
- Organization type:

Click the button below to create the organization and register your account. You'll be able to update the information above if you like.

----

- No changes to the button or "contact us" line.
- Leaving out the organization name to minimize the risk that these emails would be used to send spam.




Discussion:
Hello @zulip/server-development, @zulip/server-onboarding members, this issue was labeled with the "area: onboarding", "area: emails" labels, so you may want to check it out!

<!-- areaLabelAddition -->

@laurynmm Could you please add this one to your todo list?
Hello @pydeveloperashish!

Thanks for your interest in Zulip! You have attempted to claim an issue without the label "help wanted". You can only claim and submit pull requests for issues with the [help wanted](https://github.com/zulip/zulip/issues?q=is%3Aopen+is%3Aissue+no%3Aassignee+label%3A%22help+wanted%22) label.

If this is your first time here, we recommend reading our [guide for new contributors](https://zulip.readthedocs.io/en/latest/overview/contributing.html) before getting started.

Question about the issue description above. When you say organization URL, what we want to send is what was input in the new organization form, correct? E.g. the subdomain with the host information appended like `lauryn.zulipchat.com` for a Zulip Cloud organization. And it wouldn't be a link at this point since the organization doesn't yet exist, correct?
Yes, that sounds right -- good thought!

Resolving patch:
diff --git a/zerver/views/registration.py b/zerver/views/registration.py
--- a/zerver/views/registration.py
+++ b/zerver/views/registration.py
@@ -767,8 +767,17 @@ def send_confirm_registration_email(
     activation_url: str,
     *,
     realm: Optional[Realm] = None,
+    realm_subdomain: Optional[str] = None,
+    realm_type: Optional[int] = None,
     request: Optional[HttpRequest] = None,
 ) -> None:
+    org_url = ""
+    org_type = ""
+    if realm is None:
+        assert realm_subdomain is not None
+        org_url = f"{realm_subdomain}.{settings.EXTERNAL_HOST}"
+        assert realm_type is not None
+        org_type = get_org_type_display_name(realm_type)
     send_email(
         "zerver/emails/confirm_registration",
         to_emails=[email],
@@ -778,6 +787,8 @@ def send_confirm_registration_email(
             "create_realm": realm is None,
             "activate_url": activation_url,
             "corporate_enabled": settings.CORPORATE_ENABLED,
+            "organization_url": org_url,
+            "organization_type": org_type,
         },
         realm=realm,
         request=request,
@@ -845,7 +856,13 @@ def create_realm(request: HttpRequest, creation_key: Optional[str] = None) -> Ht
                 return HttpResponseRedirect(activation_url)
 
             try:
-                send_confirm_registration_email(email, activation_url, request=request)
+                send_confirm_registration_email(
+                    email,
+                    activation_url,
+                    realm_subdomain=realm_subdomain,
+                    realm_type=realm_type,
+                    request=request,
+                )
             except EmailNotDeliveredError:
                 logging.exception("Failed to deliver email during realm creation")
                 if settings.CORPORATE_ENABLED:


Test patch:
diff --git a/zerver/tests/test_signup.py b/zerver/tests/test_signup.py
--- a/zerver/tests/test_signup.py
+++ b/zerver/tests/test_signup.py
@@ -1406,7 +1406,9 @@ def test_create_realm_with_subdomain(self) -> None:
         self.assert_in_response("check your email", result)
 
         # Visit the confirmation link.
-        confirmation_url = self.get_confirmation_url_from_outbox(email)
+        confirmation_url = self.get_confirmation_url_from_outbox(
+            email, email_body_contains="Organization URL"
+        )
         result = self.client_get(confirmation_url)
         self.assertEqual(result.status_code, 200)
 
@@ -1779,7 +1781,9 @@ def test_create_realm_during_free_trial(self) -> None:
         result = self.client_get(result["Location"])
         self.assert_in_response("check your email", result)
 
-        confirmation_url = self.get_confirmation_url_from_outbox(email)
+        confirmation_url = self.get_confirmation_url_from_outbox(
+            email, email_body_contains="Organization URL"
+        )
         result = self.client_get(confirmation_url)
         self.assertEqual(result.status_code, 200)
 
@@ -1832,7 +1836,9 @@ def test_create_two_realms(self) -> None:
         )
         result = self.client_get(result["Location"])
         self.assert_in_response("check your email", result)
-        first_confirmation_url = self.get_confirmation_url_from_outbox(email)
+        first_confirmation_url = self.get_confirmation_url_from_outbox(
+            email, email_body_contains="Organization URL"
+        )
         self.assertEqual(PreregistrationRealm.objects.filter(email=email, status=0).count(), 1)
 
         result = self.submit_realm_creation_form(
@@ -1846,7 +1852,9 @@ def test_create_two_realms(self) -> None:
         )
         result = self.client_get(result["Location"])
         self.assert_in_response("check your email", result)
-        second_confirmation_url = self.get_confirmation_url_from_outbox(email)
+        second_confirmation_url = self.get_confirmation_url_from_outbox(
+            email, email_body_contains="Organization URL"
+        )
 
         self.assertNotEqual(first_confirmation_url, second_confirmation_url)
         self.assertEqual(PreregistrationRealm.objects.filter(email=email, status=0).count(), 2)
@@ -2119,7 +2127,9 @@ def verify_signup(
         self.assert_in_response("check your email", result)
 
         # Visit the confirmation link.
-        confirmation_url = self.get_confirmation_url_from_outbox(email)
+        confirmation_url = self.get_confirmation_url_from_outbox(
+            email, email_body_contains="You recently signed up for Zulip. Awesome!"
+        )
         result = self.client_get(confirmation_url, **client_kwargs)
         self.assertEqual(result.status_code, 200)