mirror of
https://github.com/zulip/zulip.git
synced 2025-11-01 12:33:40 +00:00
send_custom_email: Never email users who haven't agreed to ToS.
The `create_user` API and data import tools can result in our having active users in the database who haven't intentionally created a Zulip account or agreed to the ToS; we should never email such users. The check for `TOS_VERSION is not None` is necessary for the development environment, which has `TERMS_OF_SERVICE` set but not `TOS_VERSION`. It's likely that we will want this check in other places as well.
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
|
|
||||||
from zerver.lib.management import CommandError, ZulipBaseCommand
|
from zerver.lib.management import CommandError, ZulipBaseCommand
|
||||||
from zerver.lib.send_email import send_custom_email
|
from zerver.lib.send_email import send_custom_email
|
||||||
from zerver.models import Realm, UserProfile
|
from zerver.models import Realm, UserProfile
|
||||||
@@ -86,6 +88,9 @@ class Command(ZulipBaseCommand):
|
|||||||
)
|
)
|
||||||
raise error
|
raise error
|
||||||
|
|
||||||
|
# Only email users who've agreed to the terms of service.
|
||||||
|
if settings.TOS_VERSION is not None:
|
||||||
|
users = users.exclude(tos_version=None)
|
||||||
send_custom_email(users, options)
|
send_custom_email(users, options)
|
||||||
|
|
||||||
if options["dry_run"]:
|
if options["dry_run"]:
|
||||||
|
|||||||
Reference in New Issue
Block a user