mirror of https://github.com/zulip/zulip.git
find_team: Send one email per email address, not per organization.
With changes to the copy for these emails by tabbott. Fixes #19659.
This commit is contained in:
parent
a44e7a1a60
commit
4118c4a56b
|
@ -5,19 +5,13 @@
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<p>{% trans %}Hi {{ user_name }},{% endtrans %}</p>
|
<p>{% trans %}Your email address {{ email }} has accounts with the following Zulip organizations hosted by <a href="{{ external_host }}">{{ external_host }}</a>:{% endtrans %}</p>
|
||||||
|
|
||||||
<p>{% trans %}You can log in to your Zulip organization, {{ realm_name }}, at the following link:{% endtrans %}</p>
|
<ul>
|
||||||
|
{% for realm in realms %}
|
||||||
<table width="100%" border="0" cellspacing="0" cellpadding="0">
|
<li><a href="{{ realm.uri }}">{{ realm.name }} ({{ realm.host }})</a></li>
|
||||||
<tr>
|
{% endfor %}
|
||||||
<td align="center">
|
</ul>
|
||||||
<a href="{{ realm_uri }}">{{ realm_uri }}</a>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<p>{% trans %}The email address associated with your account is {{ email }}.{% endtrans %}</p>
|
|
||||||
|
|
||||||
<p>{% trans %}If you have trouble logging in, please contact Zulip support by replying to this email.{% endtrans %}</p>
|
<p>{% trans %}If you have trouble logging in, please contact Zulip support by replying to this email.{% endtrans %}</p>
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
{{ _("Your Zulip login page") }}
|
{{ _("Your Zulip accounts") }}
|
||||||
|
|
|
@ -1,16 +1,11 @@
|
||||||
{% trans -%}
|
{% trans -%}
|
||||||
Hi {{ user_name }},
|
Your email address {{ email }} has accounts with the following Zulip organizations hosted by {{ external_host }}:
|
||||||
{%- endtrans %}
|
{%- endtrans %}
|
||||||
|
|
||||||
|
|
||||||
{% trans -%}
|
{% for realm in realms %}
|
||||||
You can log in to your Zulip organization, {{ realm_name }}, at the following link:
|
* {{ realm.name }}: {{ realm.uri }}
|
||||||
{%- endtrans %}
|
{% endfor %}
|
||||||
|
|
||||||
{{ realm_uri }}
|
|
||||||
|
|
||||||
{% trans %}The email address associated with your account is {{ email }}.{% endtrans %}
|
|
||||||
|
|
||||||
|
|
||||||
{% trans %}If you have trouble logging in, please contact Zulip support by replying to this email.{% endtrans %}
|
{% trans %}If you have trouble logging in, please contact Zulip support by replying to this email.{% endtrans %}
|
||||||
|
|
||||||
|
|
|
@ -48,4 +48,4 @@ API_FEATURE_LEVEL = 98
|
||||||
# historical commits sharing the same major version, in which case a
|
# historical commits sharing the same major version, in which case a
|
||||||
# minor version bump suffices.
|
# minor version bump suffices.
|
||||||
|
|
||||||
PROVISION_VERSION = "161.1"
|
PROVISION_VERSION = "162.0"
|
||||||
|
|
|
@ -5440,8 +5440,13 @@ class TestFindMyTeam(ZulipTestCase):
|
||||||
self.assertIn("cordeliA@zulip.com", content)
|
self.assertIn("cordeliA@zulip.com", content)
|
||||||
from django.core.mail import outbox
|
from django.core.mail import outbox
|
||||||
|
|
||||||
# 3 = 1 + 2 -- Cordelia gets an email each for the "zulip" and "lear" realms.
|
self.assert_length(outbox, 2)
|
||||||
self.assert_length(outbox, 3)
|
iago_message = outbox[1]
|
||||||
|
cordelia_message = outbox[0]
|
||||||
|
self.assertIn("Zulip Dev", iago_message.body)
|
||||||
|
self.assertNotIn("Lear & Co", iago_message.body)
|
||||||
|
self.assertIn("Zulip Dev", cordelia_message.body)
|
||||||
|
self.assertIn("Lear & Co", cordelia_message.body)
|
||||||
|
|
||||||
def test_find_team_ignore_invalid_email(self) -> None:
|
def test_find_team_ignore_invalid_email(self) -> None:
|
||||||
result = self.client_post(
|
result = self.client_post(
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import logging
|
import logging
|
||||||
import urllib
|
import urllib
|
||||||
from typing import Dict, List, Optional
|
from typing import Any, Dict, List, Optional
|
||||||
from urllib.parse import urlencode
|
from urllib.parse import urlencode
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
@ -716,8 +716,6 @@ def accounts_home_from_multiuse_invite(request: HttpRequest, confirmation_key: s
|
||||||
def find_account(
|
def find_account(
|
||||||
request: HttpRequest, raw_emails: Optional[str] = REQ("emails", default=None)
|
request: HttpRequest, raw_emails: Optional[str] = REQ("emails", default=None)
|
||||||
) -> HttpResponse:
|
) -> HttpResponse:
|
||||||
from zerver.context_processors import common_context
|
|
||||||
|
|
||||||
url = reverse("find_account")
|
url = reverse("find_account")
|
||||||
|
|
||||||
emails: List[str] = []
|
emails: List[str] = []
|
||||||
|
@ -743,17 +741,32 @@ def find_account(
|
||||||
for email in emails:
|
for email in emails:
|
||||||
emails_q |= Q(delivery_email__iexact=email)
|
emails_q |= Q(delivery_email__iexact=email)
|
||||||
|
|
||||||
for user in UserProfile.objects.filter(
|
user_profiles = UserProfile.objects.filter(
|
||||||
emails_q, is_active=True, is_bot=False, realm__deactivated=False
|
emails_q, is_active=True, is_bot=False, realm__deactivated=False
|
||||||
):
|
|
||||||
context = common_context(user)
|
|
||||||
context.update(
|
|
||||||
email=user.delivery_email,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# We organize the data in preparation for sending exactly
|
||||||
|
# one outgoing email per provided email address, with each
|
||||||
|
# email listing all of the accounts that email address has
|
||||||
|
# with the current Zulip server.
|
||||||
|
context: Dict[str, Dict[str, Any]] = {}
|
||||||
|
for user in user_profiles:
|
||||||
|
key = user.delivery_email.lower()
|
||||||
|
context.setdefault(key, {})
|
||||||
|
context[key].setdefault("realms", [])
|
||||||
|
context[key]["realms"].append(user.realm)
|
||||||
|
context[key]["external_host"] = settings.EXTERNAL_HOST
|
||||||
|
# This value will end up being the last user ID among
|
||||||
|
# matching accounts; since it's only used for minor
|
||||||
|
# details like language, that arbitrary choice is OK.
|
||||||
|
context[key]["to_user_id"] = user.id
|
||||||
|
|
||||||
|
for delivery_email, realm_context in context.items():
|
||||||
|
realm_context["email"] = delivery_email
|
||||||
send_email(
|
send_email(
|
||||||
"zerver/emails/find_team",
|
"zerver/emails/find_team",
|
||||||
to_user_ids=[user.id],
|
to_user_ids=[realm_context["to_user_id"]],
|
||||||
context=context,
|
context=realm_context,
|
||||||
from_address=FromAddress.SUPPORT,
|
from_address=FromAddress.SUPPORT,
|
||||||
request=request,
|
request=request,
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue