Skip to content

Commit 87dd375

Browse files
authored
Disabled users should not receive emails (#3870)
1 parent 58cb303 commit 87dd375

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

docs/admin/deployment.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ is designed to run daily.
553553

554554
.. code-block:: bash
555555
556-
./manage.py send_oboarding_emails
556+
./manage.py send_onboarding_emails
557557
558558
Send Inactive Account Emails
559559
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

pontoon/messaging/emails.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ def send_monthly_activity_summary():
174174
log.info("Start sending Monthly activity summary emails.")
175175

176176
# Get user monthly actions
177-
users = User.objects.filter(profile__monthly_activity_summary=True)
177+
users = User.objects.filter(is_active=True, profile__monthly_activity_summary=True)
178178
user_month_actions = _get_monthly_user_actions(users, months_ago=1)
179179
previous_user_month_actions = _get_monthly_user_actions(users, months_ago=2)
180180

@@ -262,7 +262,7 @@ def send_notification_digest(frequency="Daily"):
262262
start_time = timezone.now() - datetime.timedelta(weeks=1)
263263

264264
users = (
265-
User.objects
265+
User.objects.filter(is_active=True)
266266
# Users with the selected notification email frequency
267267
.filter(profile__notification_email_frequency=frequency)
268268
# Users subscribed to at least one email notification type

pontoon/messaging/management/commands/send_oboarding_emails.py renamed to pontoon/messaging/management/commands/send_onboarding_emails.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ def handle(self, *args, **kwargs):
1313
# Send the 2nd onboarding email to users that have received the 1st email
1414
# and have joined at least ONBOARDING_EMAIL_2_DELAY days ago.
1515
users_for_email_2 = User.objects.filter(
16+
is_active=True,
1617
profile__onboarding_email_status=1,
1718
date_joined__lt=(now() - timedelta(days=settings.ONBOARDING_EMAIL_2_DELAY)),
1819
)
@@ -22,6 +23,7 @@ def handle(self, *args, **kwargs):
2223
# Send the 3rd onboarding email to users that have received the 2nd email
2324
# and have joined at least ONBOARDING_EMAIL_3_DELAY days ago.
2425
users_for_email_3 = User.objects.filter(
26+
is_active=True,
2527
profile__onboarding_email_status=2,
2628
date_joined__lt=(now() - timedelta(days=settings.ONBOARDING_EMAIL_3_DELAY)),
2729
)

0 commit comments

Comments
 (0)