Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

email: Update follow-up day 1 emails to mention demo orgs.

Eeshan Garg85b1f1bed98f
diff --git a/templates/zerver/emails/followup_day1.source.html b/templates/zerver/emails/followup_day1.source.html
index 2aa74e16607..95300a1b850 100644
--- a/templates/zerver/emails/followup_day1.source.html
+++ b/templates/zerver/emails/followup_day1.source.html
@@ -9,7 +9,11 @@
<p>
{% if realm_creation %}
- {% trans %}You've created the new Zulip organization <b>{{ realm_name }}</b>.{% endtrans %}
+ {% if is_demo_org %}
+ {% trans %}You've created a demo Zulip organization. Note that this organization will be automatically deleted in 30 days. Learn more about demo organizations <a href="https://zulip.com/help/demo-organizations">here</a>!{% endtrans %}
+ {% else %}
+ {% trans %}You've created the new Zulip organization <b>{{ realm_name }}</b>.{% endtrans %}
+ {% endif %}
{% else %}
{% trans %}You've joined the Zulip organization <b>{{ realm_name }}</b>.{% endtrans %}
{% endif %}
diff --git a/templates/zerver/emails/followup_day1.txt b/templates/zerver/emails/followup_day1.txt
index d0ed9c3bf8d..e2ed4ab8fc3 100644
--- a/templates/zerver/emails/followup_day1.txt
+++ b/templates/zerver/emails/followup_day1.txt
@@ -1,6 +1,11 @@
{{ _('Welcome to Zulip!') }}
{% if realm_creation %}
+ {% if is_demo_org %}
+ {% trans %}You've created a demo Zulip organization. Note that this organization will be automatically deleted in 30 days. Learn more about demo organizations here: https://zulip.com/help/demo-organizations{% endtrans %}
+ {% else %}
+ {% trans %}You've created the new Zulip organization {{ realm_name }}.{% endtrans %}
+ {% endif %}
{% trans %}You've created the new Zulip organization {{ realm_name }}.{% endtrans %}
{% else %}
{% trans %}You've joined the Zulip organization {{ realm_name }}.{% endtrans %}
diff --git a/zerver/lib/email_notifications.py b/zerver/lib/email_notifications.py
index c06f4b11d4e..88080932d98 100644
--- a/zerver/lib/email_notifications.py
+++ b/zerver/lib/email_notifications.py
@@ -682,6 +682,7 @@ def enqueue_welcome_emails(user: UserProfile, realm_creation: bool = False) -> N
realm_creation=realm_creation,
email=user.delivery_email,
is_realm_admin=user.is_realm_admin,
+ is_demo_org=user.realm.demo_organization_scheduled_deletion_date is not None,
)
if user.is_realm_admin:
context["getting_started_link"] = (
diff --git a/zerver/tests/test_email_notifications.py b/zerver/tests/test_email_notifications.py
index c64c03e419d..02979ea894a 100644
--- a/zerver/tests/test_email_notifications.py
+++ b/zerver/tests/test_email_notifications.py
@@ -1,5 +1,6 @@
import random
import re
+from datetime import timedelta
from email.headerregistry import Address
from typing import List, Optional, Sequence
from unittest import mock
@@ -11,6 +12,7 @@ import orjson
from django.conf import settings
from django.core import mail
from django.test import override_settings
+from django.utils.timezone import now as timezone_now
from django_auth_ldap.config import LDAPSearch
from zerver.lib.actions import do_change_user_role, do_change_user_setting
@@ -21,7 +23,7 @@ from zerver.lib.email_notifications import (
handle_missedmessage_emails,
relative_to_full_url,
)
-from zerver.lib.send_email import FromAddress, send_custom_email
+from zerver.lib.send_email import FromAddress, deliver_scheduled_emails, send_custom_email
from zerver.lib.test_classes import ZulipTestCase
from zerver.lib.user_groups import create_user_group
from zerver.models import ScheduledEmail, UserMessage, UserProfile, get_realm, get_stream
@@ -300,6 +302,43 @@ class TestFollowupEmails(ZulipTestCase):
email_data = orjson.loads(scheduled_emails[0].data)
self.assertEqual(email_data["template_prefix"], "zerver/emails/followup_day1")
+ def test_followup_emails_for_regular_realms(self) -> None:
+ cordelia = self.example_user("cordelia")
+ enqueue_welcome_emails(self.example_user("cordelia"), realm_creation=True)
+ scheduled_email = ScheduledEmail.objects.filter(users=cordelia).last()
+ self.assertEqual(
+ orjson.loads(scheduled_email.data)["template_prefix"], "zerver/emails/followup_day1"
+ )
+
+ deliver_scheduled_emails(scheduled_email)
+ from django.core.mail import outbox
+
+ self.assert_length(outbox, 1)
+
+ message = outbox[0]
+ self.assertIn("You've created the new Zulip organization", message.body)
+ self.assertNotIn("demo org", message.body)
+
+ def test_followup_emails_for_demo_realms(self) -> None:
+ cordelia = self.example_user("cordelia")
+ cordelia.realm.demo_organization_scheduled_deletion_date = timezone_now() + timedelta(
+ days=30
+ )
+ cordelia.realm.save()
+ enqueue_welcome_emails(self.example_user("cordelia"), realm_creation=True)
+ scheduled_email = ScheduledEmail.objects.filter(users=cordelia).last()
+ self.assertEqual(
+ orjson.loads(scheduled_email.data)["template_prefix"], "zerver/emails/followup_day1"
+ )
+
+ deliver_scheduled_emails(scheduled_email)
+ from django.core.mail import outbox
+
+ self.assert_length(outbox, 1)
+
+ message = outbox[0]
+ self.assertIn("You've created a demo Zulip organization", message.body)
+
class TestMissedMessages(ZulipTestCase):
def test_read_message(self) -> None: