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: Fix emailing single users with TOS_VERSION set.

Tim Abbott9968fb5081db
diff --git a/zerver/management/commands/send_custom_email.py b/zerver/management/commands/send_custom_email.py
index 52855e86806..ab1ed9b7db3 100644
--- a/zerver/management/commands/send_custom_email.py
+++ b/zerver/management/commands/send_custom_email.py
@@ -111,7 +111,13 @@ class Command(ZulipBaseCommand):
# Only email users who've agreed to the terms of service.
if settings.TOS_VERSION is not None:
- users = users.exclude(tos_version=None)
+ # We need to do a new query because the `get_users` path
+ # passes us a list rather than a QuerySet.
+ users = (
+ UserProfile.objects.select_related()
+ .filter(id__in=[u.id for u in users])
+ .exclude(tos_version=None)
+ )
send_custom_email(users, options)
if options["dry_run"]: