mirror of
https://github.com/zulip/zulip.git
synced 2026-07-06 21:18:58 +08:00
send_custom_email: Add option for sending marketing emails.
This commit is contained in:
parent
f452e176da
commit
d1dd34d7e0
@ -3,6 +3,7 @@ from typing import Any
|
||||
|
||||
from django.conf import settings
|
||||
from django.core.management.base import CommandError
|
||||
from django.db.models import Q
|
||||
|
||||
from zerver.lib.management import ZulipBaseCommand
|
||||
from zerver.lib.send_email import send_custom_email
|
||||
@ -27,6 +28,11 @@ class Command(ZulipBaseCommand):
|
||||
action="store_true",
|
||||
help="Send to all organization administrators of sponsored organizations.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--marketing",
|
||||
action="store_true",
|
||||
help="Send to active users and realm owners with the enable_marketing_emails setting enabled.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--markdown-template-path",
|
||||
"--path",
|
||||
@ -63,6 +69,20 @@ class Command(ZulipBaseCommand):
|
||||
users = UserProfile.objects.filter(
|
||||
is_active=True, is_bot=False, is_mirror_dummy=False, realm__deactivated=False
|
||||
)
|
||||
elif options["marketing"]:
|
||||
# Marketing email sent at most once to each email address for users
|
||||
# who are either recently active (!long_term_idle) or are a realm owner.
|
||||
users = (
|
||||
UserProfile.objects.filter(
|
||||
is_active=True,
|
||||
is_bot=False,
|
||||
is_mirror_dummy=False,
|
||||
realm__deactivated=False,
|
||||
enable_marketing_emails=True,
|
||||
)
|
||||
.filter(Q(long_term_idle=False) | Q(role=UserProfile.ROLE_REALM_OWNER))
|
||||
.distinct("delivery_email")
|
||||
)
|
||||
elif options["all_sponsored_org_admins"]:
|
||||
# Sends at most one copy to each email address, even if it
|
||||
# is an administrator in several organizations.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user