Enable missed message notifications for zulip.com

Also increase the number of messages sent as context from 5 to 10 and
look up to 15 minutes in to the past for context.

(imported from commit bfaed9bcff1ee2047fc3b7a63acf93cd2d47cc7d)
This commit is contained in:
Jason Michalski 2015-02-20 20:46:19 -05:00
parent d3822c5d7b
commit 802a3dd357
3 changed files with 11 additions and 10 deletions

View File

@ -203,8 +203,7 @@ def do_send_missedmessage_events_reply_in_zulip(user_profile, missed_messages, m
all have the same recipient and subject
"""
# Disabled missedmessage emails internally
if (not user_profile.enable_offline_email_notifications
or user_profile.realm.domain == "zulip.com"):
if not user_profile.enable_offline_email_notifications:
return
recipients = set((msg.recipient_id, msg.subject) for msg in missed_messages)
@ -257,8 +256,7 @@ def do_send_missedmessage_events(user_profile, missed_messages, message_count):
`missed_messages` is a list of Message objects to remind about
"""
# Disabled missedmessage emails internally
if (not user_profile.enable_offline_email_notifications
or user_profile.realm.domain == "zulip.com"):
if not user_profile.enable_offline_email_notifications:
return
senders = set(m.sender.full_name for m in missed_messages)

View File

@ -983,8 +983,8 @@ def get_context_for_message(message):
recipient_id=message.recipient_id,
subject=message.subject,
id__lt=message.id,
pub_date__gt=message.pub_date - timedelta(minutes=5),
).order_by('-id')[:5]
pub_date__gt=message.pub_date - timedelta(minutes=15),
).order_by('-id')[:10]
class UserMessage(models.Model):

View File

@ -1399,15 +1399,18 @@ class ExtractedRecipientsTest(TestCase):
class TestMissedMessages(AuthedTestCase):
def test_extra_context_in_missed_stream_messages(self):
# missed messages are disabled for zulip.com and only zulip.com has extra context
return
self.send_message("othello@zulip.com", "Denmark", Recipient.STREAM, '0')
self.send_message("othello@zulip.com", "Denmark", Recipient.STREAM, '1')
self.send_message("othello@zulip.com", "Denmark", Recipient.STREAM, '2')
self.send_message("othello@zulip.com", "Denmark", Recipient.STREAM, '3')
self.send_message("othello@zulip.com", "Denmark", Recipient.STREAM, '4')
self.send_message("othello@zulip.com", "Denmark", Recipient.STREAM, '5')
self.send_message("othello@zulip.com", "Denmark", Recipient.STREAM, '6', subject='test2')
self.send_message("othello@zulip.com", "Denmark", Recipient.STREAM, '6')
self.send_message("othello@zulip.com", "Denmark", Recipient.STREAM, '7')
self.send_message("othello@zulip.com", "Denmark", Recipient.STREAM, '8')
self.send_message("othello@zulip.com", "Denmark", Recipient.STREAM, '9')
self.send_message("othello@zulip.com", "Denmark", Recipient.STREAM, '10')
self.send_message("othello@zulip.com", "Denmark", Recipient.STREAM, '11', subject='test2')
msg_id = self.send_message("othello@zulip.com", "denmark", Recipient.STREAM, '@**hamlet**')
hamlet = get_user_profile_by_email('hamlet@zulip.com')
@ -1419,6 +1422,6 @@ class TestMissedMessages(AuthedTestCase):
self.assertEquals(len(mail.outbox), 1)
self.assertIn(
'Denmark > test Othello, the Moor of Venice 1 2 3 4 5 @**hamlet**',
'Denmark > test Othello, the Moor of Venice 1 2 3 4 5 6 7 8 9 10 @**hamlet**',
normalize_string(mail.outbox[0].body),
)