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.

send_custom_email: Make options a mandatory kwarg.

Tim Abbottf287606198aa
diff --git a/zerver/lib/send_email.py b/zerver/lib/send_email.py
index 8e2b5b97426..6aabc605601 100644
--- a/zerver/lib/send_email.py
+++ b/zerver/lib/send_email.py
@@ -495,7 +495,7 @@ def get_header(option: Optional[str], header: Optional[str], name: str) -> str:
return str(option or header)
-def send_custom_email(users: List[UserProfile], options: Dict[str, Any]) -> None:
+def send_custom_email(users: List[UserProfile], *, options: Dict[str, Any]) -> None:
"""
Can be used directly with from a management shell with
send_custom_email(user_profile_list, dict(
diff --git a/zerver/management/commands/send_custom_email.py b/zerver/management/commands/send_custom_email.py
index 0b0bdcf08a0..2723dbde500 100644
--- a/zerver/management/commands/send_custom_email.py
+++ b/zerver/management/commands/send_custom_email.py
@@ -114,7 +114,7 @@ class Command(ZulipBaseCommand):
.filter(id__in=[u.id for u in users])
.exclude(tos_version=None)
)
- send_custom_email(users, options)
+ send_custom_email(users, options=options)
if options["dry_run"]:
print("Would send the above email to:")
diff --git a/zerver/tests/test_email_notifications.py b/zerver/tests/test_email_notifications.py
index cd43c342b3b..1b3c0da5539 100644
--- a/zerver/tests/test_email_notifications.py
+++ b/zerver/tests/test_email_notifications.py
@@ -38,7 +38,7 @@ class TestCustomEmails(ZulipTestCase):
markdown_template_path = "templates/zerver/emails/email_base_default.source.html"
send_custom_email(
[hamlet],
- {
+ options={
"markdown_template_path": markdown_template_path,
"reply_to": reply_to,
"subject": email_subject,
@@ -60,7 +60,7 @@ class TestCustomEmails(ZulipTestCase):
)
send_custom_email(
[hamlet],
- {
+ options={
"markdown_template_path": markdown_template_path,
"dry_run": False,
},
@@ -83,7 +83,7 @@ class TestCustomEmails(ZulipTestCase):
NoEmailArgumentException,
send_custom_email,
[hamlet],
- {
+ options={
"markdown_template_path": markdown_template_path,
"from_name": from_name,
"dry_run": False,
@@ -94,7 +94,7 @@ class TestCustomEmails(ZulipTestCase):
NoEmailArgumentException,
send_custom_email,
[hamlet],
- {
+ options={
"markdown_template_path": markdown_template_path,
"subject": email_subject,
"dry_run": False,
@@ -115,7 +115,7 @@ class TestCustomEmails(ZulipTestCase):
DoubledEmailArgumentException,
send_custom_email,
[hamlet],
- {
+ options={
"markdown_template_path": markdown_template_path,
"subject": email_subject,
"dry_run": False,
@@ -126,7 +126,7 @@ class TestCustomEmails(ZulipTestCase):
DoubledEmailArgumentException,
send_custom_email,
[hamlet],
- {
+ options={
"markdown_template_path": markdown_template_path,
"from_name": from_name,
"dry_run": False,
@@ -144,7 +144,7 @@ class TestCustomEmails(ZulipTestCase):
)
send_custom_email(
[admin_user, non_admin_user],
- {
+ options={
"markdown_template_path": markdown_template_path,
"admins_only": True,
"dry_run": False,
@@ -162,7 +162,7 @@ class TestCustomEmails(ZulipTestCase):
with patch("builtins.print") as _:
send_custom_email(
[hamlet],
- {
+ options={
"markdown_template_path": markdown_template_path,
"reply_to": reply_to,
"subject": email_subject,