mirror of
https://github.com/zulip/zulip.git
synced 2025-11-21 23:19:10 +00:00
Reset our 24hr email blackout when a user logs in
(imported from commit 93bed7c4d049ba4d7b30d2e02fbbe0d2debca6f8)
This commit is contained in:
@@ -1215,8 +1215,9 @@ def handle_missedmessage_emails(user_profile_id, missed_email_events):
|
||||
message__id__in=message_ids,
|
||||
flags=~UserMessage.flags.read)]
|
||||
|
||||
if len(messages) == 0 or (user_profile.last_reminder and
|
||||
timestamp - user_profile.last_reminder < datetime.timedelta(days=1)):
|
||||
waitperiod = datetime.timedelta(hours=UserProfile.EMAIL_REMINDER_WAITPERIOD)
|
||||
if len(messages) == 0 or (user_profile.last_reminder and \
|
||||
timestamp - user_profile.last_reminder < waitperiod):
|
||||
# Don't spam the user, if we've sent an email in the last day
|
||||
return
|
||||
|
||||
|
||||
@@ -91,6 +91,9 @@ class UserProfile(AbstractBaseUser):
|
||||
enable_offline_email_notifications = models.BooleanField(default=True)
|
||||
last_reminder = models.DateTimeField(default=timezone.now, null=True)
|
||||
|
||||
# Hours to wait before sending another email to a user
|
||||
EMAIL_REMINDER_WAITPERIOD = 24
|
||||
|
||||
TUTORIAL_WAITING = 'W'
|
||||
TUTORIAL_STARTED = 'S'
|
||||
TUTORIAL_FINISHED = 'F'
|
||||
|
||||
@@ -501,6 +501,12 @@ def home(request):
|
||||
apply_markdown=True)
|
||||
user_has_messages = (register_ret['max_message_id'] != -1)
|
||||
|
||||
# Reset our don't-spam-users-with-email counter since the
|
||||
# user has since logged in
|
||||
if not user_profile.last_reminder is None:
|
||||
user_profile.last_reminder = None
|
||||
user_profile.save()
|
||||
|
||||
# Brand new users get the tutorial
|
||||
needs_tutorial = settings.TUTORIAL_ENABLED and \
|
||||
user_profile.tutorial_status == UserProfile.TUTORIAL_WAITING
|
||||
|
||||
Reference in New Issue
Block a user