2017-03-08 12:28:24 +01:00
|
|
|
from __future__ import absolute_import
|
|
|
|
from __future__ import print_function
|
|
|
|
|
|
|
|
import random
|
|
|
|
import re
|
|
|
|
|
|
|
|
from django.conf import settings
|
|
|
|
from django.core import mail
|
|
|
|
from django.http import HttpResponse
|
|
|
|
from django.test import override_settings
|
2017-07-02 04:49:34 +02:00
|
|
|
from email.utils import formataddr
|
2017-03-08 12:28:24 +01:00
|
|
|
from mock import patch, MagicMock
|
2017-03-08 20:36:04 +01:00
|
|
|
from six.moves import range
|
2017-03-08 12:28:24 +01:00
|
|
|
from typing import Any, Dict, List, Text
|
|
|
|
|
|
|
|
from zerver.lib.notifications import handle_missedmessage_emails
|
2017-03-14 08:38:01 +01:00
|
|
|
from zerver.lib.actions import render_incoming_message, do_update_message
|
|
|
|
from zerver.lib.message import access_message
|
2017-03-08 12:28:24 +01:00
|
|
|
from zerver.lib.test_classes import ZulipTestCase
|
2017-06-26 19:43:32 +02:00
|
|
|
from zerver.lib.send_email import FromAddress
|
2017-05-08 17:54:11 +02:00
|
|
|
from zerver.models import (
|
|
|
|
Recipient,
|
|
|
|
UserMessage,
|
|
|
|
UserProfile,
|
|
|
|
)
|
2017-07-07 22:34:22 +02:00
|
|
|
from zerver.lib.test_helpers import get_test_image_file
|
2017-03-08 12:28:24 +01:00
|
|
|
|
|
|
|
class TestMissedMessages(ZulipTestCase):
|
|
|
|
def normalize_string(self, s):
|
|
|
|
# type: (Text) -> Text
|
|
|
|
s = s.strip()
|
|
|
|
return re.sub(r'\s+', ' ', s)
|
|
|
|
|
|
|
|
def _get_tokens(self):
|
|
|
|
# type: () -> List[str]
|
|
|
|
return [str(random.getrandbits(32)) for _ in range(30)]
|
|
|
|
|
2017-07-07 22:34:22 +02:00
|
|
|
def _test_cases(self, tokens, msg_id, body, subject, send_as_user, verify_html_body=False):
|
|
|
|
# type: (List[str], int, str, str, bool, bool) -> None
|
2017-05-07 17:21:26 +02:00
|
|
|
othello = self.example_user('othello')
|
|
|
|
hamlet = self.example_user('hamlet')
|
2017-03-08 12:28:24 +01:00
|
|
|
handle_missedmessage_emails(hamlet.id, [{'message_id': msg_id}])
|
2017-03-08 04:46:49 +01:00
|
|
|
if settings.EMAIL_GATEWAY_PATTERN != "":
|
|
|
|
reply_to_addresses = [settings.EMAIL_GATEWAY_PATTERN % (u'mm' + t) for t in tokens]
|
2017-06-26 19:43:32 +02:00
|
|
|
reply_to_emails = [formataddr(("Zulip", address)) for address in reply_to_addresses]
|
2017-03-08 04:46:49 +01:00
|
|
|
else:
|
2017-08-16 03:32:36 +02:00
|
|
|
reply_to_emails = ["noreply@testserver"]
|
2017-03-08 12:28:24 +01:00
|
|
|
msg = mail.outbox[0]
|
2017-07-25 22:55:09 +02:00
|
|
|
from_email = formataddr(("Zulip missed messages", FromAddress.NOREPLY))
|
2017-03-08 12:28:24 +01:00
|
|
|
self.assertEqual(len(mail.outbox), 1)
|
|
|
|
if send_as_user:
|
|
|
|
from_email = '"%s" <%s>' % (othello.full_name, othello.email)
|
|
|
|
self.assertEqual(msg.from_email, from_email)
|
2017-05-03 09:22:58 +02:00
|
|
|
self.assertEqual(msg.subject, subject)
|
2017-05-05 01:31:07 +02:00
|
|
|
self.assertEqual(len(msg.reply_to), 1)
|
2017-06-26 19:43:32 +02:00
|
|
|
self.assertIn(msg.reply_to[0], reply_to_emails)
|
2017-07-07 22:34:22 +02:00
|
|
|
if verify_html_body:
|
|
|
|
self.assertIn(body, self.normalize_string(msg.alternatives[0][0]))
|
|
|
|
else:
|
|
|
|
self.assertIn(body, self.normalize_string(msg.body))
|
2017-03-08 12:28:24 +01:00
|
|
|
|
|
|
|
@patch('zerver.lib.email_mirror.generate_random_token')
|
2017-05-12 22:47:34 +02:00
|
|
|
def _extra_context_in_missed_stream_messages_mention(self, send_as_user, mock_random_token):
|
2017-03-08 12:28:24 +01:00
|
|
|
# type: (bool, MagicMock) -> None
|
|
|
|
tokens = self._get_tokens()
|
|
|
|
mock_random_token.side_effect = tokens
|
|
|
|
|
|
|
|
for i in range(0, 11):
|
2017-05-24 05:08:49 +02:00
|
|
|
self.send_message(self.example_email('othello'), "Denmark", Recipient.STREAM, str(i))
|
|
|
|
self.send_message(self.example_email('othello'), "Denmark", Recipient.STREAM, '11', subject='test2')
|
2017-06-19 17:03:04 +02:00
|
|
|
msg_id = self.send_message(self.example_email('othello'), "denmark", Recipient.STREAM, '@**King Hamlet**')
|
|
|
|
body = 'Denmark > test Othello, the Moor of Venice 1 2 3 4 5 6 7 8 9 10 @**King Hamlet**'
|
2017-07-14 03:33:35 +02:00
|
|
|
subject = 'Othello, the Moor of Venice mentioned you'
|
2017-05-03 09:22:58 +02:00
|
|
|
self._test_cases(tokens, msg_id, body, subject, send_as_user)
|
2017-03-08 12:28:24 +01:00
|
|
|
|
2017-05-12 22:47:34 +02:00
|
|
|
@patch('zerver.lib.email_mirror.generate_random_token')
|
|
|
|
def _extra_context_in_missed_stream_messages_mention_two_senders(self, send_as_user, mock_random_token):
|
|
|
|
# type: (bool, MagicMock) -> None
|
|
|
|
tokens = self._get_tokens()
|
|
|
|
mock_random_token.side_effect = tokens
|
|
|
|
|
|
|
|
for i in range(0, 3):
|
2017-05-24 05:08:49 +02:00
|
|
|
self.send_message(self.example_email('cordelia'), "Denmark", Recipient.STREAM, str(i))
|
2017-06-19 17:03:04 +02:00
|
|
|
msg_id = self.send_message(self.example_email('othello'), "Denmark", Recipient.STREAM, '@**King Hamlet**')
|
|
|
|
body = 'Denmark > test Cordelia Lear 0 1 2 Othello, the Moor of Venice @**King Hamlet**'
|
2017-07-14 03:33:35 +02:00
|
|
|
subject = 'Othello, the Moor of Venice mentioned you'
|
2017-05-12 22:47:34 +02:00
|
|
|
self._test_cases(tokens, msg_id, body, subject, send_as_user)
|
|
|
|
|
2017-03-08 12:28:24 +01:00
|
|
|
@patch('zerver.lib.email_mirror.generate_random_token')
|
|
|
|
def _extra_context_in_personal_missed_stream_messages(self, send_as_user, mock_random_token):
|
|
|
|
# type: (bool, MagicMock) -> None
|
|
|
|
tokens = self._get_tokens()
|
|
|
|
mock_random_token.side_effect = tokens
|
|
|
|
|
2017-05-24 05:08:49 +02:00
|
|
|
msg_id = self.send_message(self.example_email('othello'), self.example_email('hamlet'),
|
2017-03-08 12:28:24 +01:00
|
|
|
Recipient.PERSONAL,
|
|
|
|
'Extremely personal message!')
|
|
|
|
body = 'You and Othello, the Moor of Venice Extremely personal message!'
|
2017-07-14 03:33:35 +02:00
|
|
|
subject = 'Othello, the Moor of Venice sent you a message'
|
2017-05-03 09:22:58 +02:00
|
|
|
self._test_cases(tokens, msg_id, body, subject, send_as_user)
|
2017-03-08 12:28:24 +01:00
|
|
|
|
2017-03-08 04:46:49 +01:00
|
|
|
@patch('zerver.lib.email_mirror.generate_random_token')
|
|
|
|
def _reply_to_email_in_personal_missed_stream_messages(self, send_as_user, mock_random_token):
|
|
|
|
# type: (bool, MagicMock) -> None
|
|
|
|
tokens = self._get_tokens()
|
|
|
|
mock_random_token.side_effect = tokens
|
|
|
|
|
2017-05-24 05:08:49 +02:00
|
|
|
msg_id = self.send_message(self.example_email('othello'), self.example_email('hamlet'),
|
2017-03-08 04:46:49 +01:00
|
|
|
Recipient.PERSONAL,
|
|
|
|
'Extremely personal message!')
|
|
|
|
body = 'Or just reply to this email.'
|
2017-07-14 03:33:35 +02:00
|
|
|
subject = 'Othello, the Moor of Venice sent you a message'
|
2017-05-03 09:22:58 +02:00
|
|
|
self._test_cases(tokens, msg_id, body, subject, send_as_user)
|
2017-03-08 04:46:49 +01:00
|
|
|
|
|
|
|
@patch('zerver.lib.email_mirror.generate_random_token')
|
|
|
|
def _reply_warning_in_personal_missed_stream_messages(self, send_as_user, mock_random_token):
|
|
|
|
# type: (bool, MagicMock) -> None
|
|
|
|
tokens = self._get_tokens()
|
|
|
|
mock_random_token.side_effect = tokens
|
|
|
|
|
2017-05-24 05:08:49 +02:00
|
|
|
msg_id = self.send_message(self.example_email('othello'), self.example_email('hamlet'),
|
2017-03-08 04:46:49 +01:00
|
|
|
Recipient.PERSONAL,
|
|
|
|
'Extremely personal message!')
|
|
|
|
body = 'Please do not reply to this automated message.'
|
2017-07-14 03:33:35 +02:00
|
|
|
subject = 'Othello, the Moor of Venice sent you a message'
|
2017-05-03 09:22:58 +02:00
|
|
|
self._test_cases(tokens, msg_id, body, subject, send_as_user)
|
2017-03-08 04:46:49 +01:00
|
|
|
|
2017-03-08 12:28:24 +01:00
|
|
|
@patch('zerver.lib.email_mirror.generate_random_token')
|
2017-05-03 09:22:58 +02:00
|
|
|
def _extra_context_in_huddle_missed_stream_messages_two_others(self, send_as_user, mock_random_token):
|
2017-03-08 12:28:24 +01:00
|
|
|
# type: (bool, MagicMock) -> None
|
|
|
|
tokens = self._get_tokens()
|
|
|
|
mock_random_token.side_effect = tokens
|
|
|
|
|
2017-05-24 05:08:49 +02:00
|
|
|
msg_id = self.send_message(self.example_email('othello'),
|
|
|
|
[self.example_email('hamlet'), self.example_email('iago')],
|
2017-05-03 09:22:58 +02:00
|
|
|
Recipient.HUDDLE,
|
2017-03-08 12:28:24 +01:00
|
|
|
'Group personal message!')
|
|
|
|
|
|
|
|
body = ('You and Iago, Othello, the Moor of Venice Othello,'
|
|
|
|
' the Moor of Venice Group personal message')
|
2017-07-14 03:33:35 +02:00
|
|
|
subject = 'Group PMs with Iago and Othello, the Moor of Venice'
|
2017-05-03 09:22:58 +02:00
|
|
|
self._test_cases(tokens, msg_id, body, subject, send_as_user)
|
|
|
|
|
|
|
|
@patch('zerver.lib.email_mirror.generate_random_token')
|
|
|
|
def _extra_context_in_huddle_missed_stream_messages_three_others(self, send_as_user, mock_random_token):
|
|
|
|
# type: (bool, MagicMock) -> None
|
|
|
|
tokens = self._get_tokens()
|
|
|
|
mock_random_token.side_effect = tokens
|
|
|
|
|
2017-05-24 05:08:49 +02:00
|
|
|
msg_id = self.send_message(self.example_email('othello'),
|
|
|
|
[self.example_email('hamlet'), self.example_email('iago'), self.example_email('cordelia')],
|
2017-05-03 09:22:58 +02:00
|
|
|
Recipient.HUDDLE,
|
|
|
|
'Group personal message!')
|
|
|
|
|
|
|
|
body = ('You and Cordelia Lear, Iago, Othello, the Moor of Venice Othello,'
|
|
|
|
' the Moor of Venice Group personal message')
|
2017-07-14 03:33:35 +02:00
|
|
|
subject = 'Group PMs with Cordelia Lear, Iago, and Othello, the Moor of Venice'
|
2017-05-03 09:22:58 +02:00
|
|
|
self._test_cases(tokens, msg_id, body, subject, send_as_user)
|
|
|
|
|
|
|
|
@patch('zerver.lib.email_mirror.generate_random_token')
|
|
|
|
def _extra_context_in_huddle_missed_stream_messages_many_others(self, send_as_user, mock_random_token):
|
|
|
|
# type: (bool, MagicMock) -> None
|
|
|
|
tokens = self._get_tokens()
|
|
|
|
mock_random_token.side_effect = tokens
|
|
|
|
|
2017-05-24 05:08:49 +02:00
|
|
|
msg_id = self.send_message(self.example_email('othello'),
|
|
|
|
[self.example_email('hamlet'),
|
|
|
|
self.example_email('iago'),
|
|
|
|
self.example_email('cordelia'),
|
|
|
|
self.example_email('prospero')],
|
2017-05-03 09:22:58 +02:00
|
|
|
Recipient.HUDDLE,
|
|
|
|
'Group personal message!')
|
|
|
|
|
|
|
|
body = ('You and Cordelia Lear, Iago, Othello, the Moor of Venice, Prospero from The Tempest'
|
|
|
|
' Othello, the Moor of Venice Group personal message')
|
2017-07-14 03:33:35 +02:00
|
|
|
subject = 'Group PMs with Cordelia Lear, Iago, and 2 others'
|
2017-05-03 09:22:58 +02:00
|
|
|
self._test_cases(tokens, msg_id, body, subject, send_as_user)
|
2017-03-08 12:28:24 +01:00
|
|
|
|
2017-03-14 08:38:01 +01:00
|
|
|
@patch('zerver.lib.email_mirror.generate_random_token')
|
|
|
|
def _deleted_message_in_missed_stream_messages(self, send_as_user, mock_random_token):
|
|
|
|
# type: (bool, MagicMock) -> None
|
|
|
|
tokens = self._get_tokens()
|
|
|
|
mock_random_token.side_effect = tokens
|
|
|
|
|
2017-05-24 05:08:49 +02:00
|
|
|
msg_id = self.send_message(self.example_email('othello'), "denmark", Recipient.STREAM,
|
2017-06-19 17:03:04 +02:00
|
|
|
'@**King Hamlet** to be deleted')
|
2017-03-14 08:38:01 +01:00
|
|
|
|
2017-05-07 17:21:26 +02:00
|
|
|
hamlet = self.example_user('hamlet')
|
2017-05-24 05:08:49 +02:00
|
|
|
email = self.example_email('othello')
|
|
|
|
self.login(email)
|
2017-03-14 08:38:01 +01:00
|
|
|
result = self.client_patch('/json/messages/' + str(msg_id),
|
2017-03-23 21:06:04 +01:00
|
|
|
{'message_id': msg_id, 'content': ' '})
|
2017-03-14 08:38:01 +01:00
|
|
|
self.assert_json_success(result)
|
|
|
|
handle_missedmessage_emails(hamlet.id, [{'message_id': msg_id}])
|
|
|
|
self.assertEqual(len(mail.outbox), 0)
|
|
|
|
|
|
|
|
@patch('zerver.lib.email_mirror.generate_random_token')
|
|
|
|
def _deleted_message_in_personal_missed_stream_messages(self, send_as_user, mock_random_token):
|
|
|
|
# type: (bool, MagicMock) -> None
|
|
|
|
tokens = self._get_tokens()
|
|
|
|
mock_random_token.side_effect = tokens
|
|
|
|
|
2017-05-24 05:08:49 +02:00
|
|
|
msg_id = self.send_message(self.example_email('othello'),
|
|
|
|
self.example_email('hamlet'),
|
|
|
|
Recipient.PERSONAL,
|
2017-03-14 08:38:01 +01:00
|
|
|
'Extremely personal message! to be deleted!')
|
|
|
|
|
2017-05-07 17:21:26 +02:00
|
|
|
hamlet = self.example_user('hamlet')
|
2017-05-24 05:08:49 +02:00
|
|
|
email = self.example_email('othello')
|
|
|
|
self.login(email)
|
2017-03-14 08:38:01 +01:00
|
|
|
result = self.client_patch('/json/messages/' + str(msg_id),
|
2017-03-23 21:06:04 +01:00
|
|
|
{'message_id': msg_id, 'content': ' '})
|
2017-03-14 08:38:01 +01:00
|
|
|
self.assert_json_success(result)
|
|
|
|
handle_missedmessage_emails(hamlet.id, [{'message_id': msg_id}])
|
|
|
|
self.assertEqual(len(mail.outbox), 0)
|
|
|
|
|
|
|
|
@patch('zerver.lib.email_mirror.generate_random_token')
|
|
|
|
def _deleted_message_in_huddle_missed_stream_messages(self, send_as_user, mock_random_token):
|
|
|
|
# type: (bool, MagicMock) -> None
|
|
|
|
tokens = self._get_tokens()
|
|
|
|
mock_random_token.side_effect = tokens
|
|
|
|
|
2017-05-24 05:08:49 +02:00
|
|
|
msg_id = self.send_message(self.example_email('othello'),
|
|
|
|
[self.example_email('hamlet'),
|
|
|
|
self.example_email('iago')],
|
2017-03-14 08:38:01 +01:00
|
|
|
Recipient.PERSONAL, 'Group personal message!')
|
|
|
|
|
2017-05-07 17:21:26 +02:00
|
|
|
hamlet = self.example_user('hamlet')
|
|
|
|
iago = self.example_user('iago')
|
2017-05-24 05:08:49 +02:00
|
|
|
email = self.example_email('othello')
|
|
|
|
self.login(email)
|
2017-03-14 08:38:01 +01:00
|
|
|
result = self.client_patch('/json/messages/' + str(msg_id),
|
2017-03-23 21:06:04 +01:00
|
|
|
{'message_id': msg_id, 'content': ' '})
|
2017-03-14 08:38:01 +01:00
|
|
|
self.assert_json_success(result)
|
|
|
|
handle_missedmessage_emails(hamlet.id, [{'message_id': msg_id}])
|
|
|
|
self.assertEqual(len(mail.outbox), 0)
|
|
|
|
handle_missedmessage_emails(iago.id, [{'message_id': msg_id}])
|
|
|
|
self.assertEqual(len(mail.outbox), 0)
|
|
|
|
|
2017-03-08 12:28:24 +01:00
|
|
|
@override_settings(SEND_MISSED_MESSAGE_EMAILS_AS_USER=True)
|
|
|
|
def test_extra_context_in_missed_stream_messages_as_user(self):
|
|
|
|
# type: () -> None
|
2017-05-12 22:47:34 +02:00
|
|
|
self._extra_context_in_missed_stream_messages_mention(True)
|
2017-03-08 12:28:24 +01:00
|
|
|
|
|
|
|
def test_extra_context_in_missed_stream_messages(self):
|
|
|
|
# type: () -> None
|
2017-05-12 22:47:34 +02:00
|
|
|
self._extra_context_in_missed_stream_messages_mention(False)
|
|
|
|
|
|
|
|
@override_settings(SEND_MISSED_MESSAGE_EMAILS_AS_USER=True)
|
|
|
|
def test_extra_context_in_missed_stream_messages_as_user_two_senders(self):
|
|
|
|
# type: () -> None
|
|
|
|
self._extra_context_in_missed_stream_messages_mention_two_senders(True)
|
|
|
|
|
|
|
|
def test_extra_context_in_missed_stream_messages_two_senders(self):
|
|
|
|
# type: () -> None
|
|
|
|
self._extra_context_in_missed_stream_messages_mention_two_senders(False)
|
2017-03-08 12:28:24 +01:00
|
|
|
|
2017-03-08 04:46:49 +01:00
|
|
|
def test_reply_to_email_in_personal_missed_stream_messages(self):
|
|
|
|
# type: () -> None
|
|
|
|
self._reply_to_email_in_personal_missed_stream_messages(False)
|
|
|
|
|
|
|
|
@override_settings(EMAIL_GATEWAY_PATTERN="")
|
|
|
|
def test_reply_warning_in_personal_missed_stream_messages(self):
|
|
|
|
# type: () -> None
|
|
|
|
self._reply_warning_in_personal_missed_stream_messages(False)
|
|
|
|
|
2017-03-08 12:28:24 +01:00
|
|
|
@override_settings(SEND_MISSED_MESSAGE_EMAILS_AS_USER=True)
|
|
|
|
def test_extra_context_in_personal_missed_stream_messages_as_user(self):
|
|
|
|
# type: () -> None
|
|
|
|
self._extra_context_in_personal_missed_stream_messages(True)
|
|
|
|
|
|
|
|
def test_extra_context_in_personal_missed_stream_messages(self):
|
|
|
|
# type: () -> None
|
|
|
|
self._extra_context_in_personal_missed_stream_messages(False)
|
|
|
|
|
|
|
|
@override_settings(SEND_MISSED_MESSAGE_EMAILS_AS_USER=True)
|
2017-05-03 09:22:58 +02:00
|
|
|
def test_extra_context_in_huddle_missed_stream_messages_two_others_as_user(self):
|
|
|
|
# type: () -> None
|
|
|
|
self._extra_context_in_huddle_missed_stream_messages_two_others(True)
|
|
|
|
|
|
|
|
def test_extra_context_in_huddle_missed_stream_messages_two_others(self):
|
|
|
|
# type: () -> None
|
|
|
|
self._extra_context_in_huddle_missed_stream_messages_two_others(False)
|
|
|
|
|
|
|
|
@override_settings(SEND_MISSED_MESSAGE_EMAILS_AS_USER=True)
|
|
|
|
def test_extra_context_in_huddle_missed_stream_messages_three_others_as_user(self):
|
|
|
|
# type: () -> None
|
|
|
|
self._extra_context_in_huddle_missed_stream_messages_three_others(True)
|
|
|
|
|
|
|
|
def test_extra_context_in_huddle_missed_stream_messages_three_others(self):
|
|
|
|
# type: () -> None
|
|
|
|
self._extra_context_in_huddle_missed_stream_messages_three_others(False)
|
|
|
|
|
|
|
|
@override_settings(SEND_MISSED_MESSAGE_EMAILS_AS_USER=True)
|
|
|
|
def test_extra_context_in_huddle_missed_stream_messages_many_others_as_user(self):
|
2017-03-08 12:28:24 +01:00
|
|
|
# type: () -> None
|
2017-05-03 09:22:58 +02:00
|
|
|
self._extra_context_in_huddle_missed_stream_messages_many_others(True)
|
2017-03-08 12:28:24 +01:00
|
|
|
|
2017-05-03 09:22:58 +02:00
|
|
|
def test_extra_context_in_huddle_missed_stream_messages_many_others(self):
|
2017-03-08 12:28:24 +01:00
|
|
|
# type: () -> None
|
2017-05-03 09:22:58 +02:00
|
|
|
self._extra_context_in_huddle_missed_stream_messages_many_others(False)
|
2017-03-14 08:38:01 +01:00
|
|
|
|
|
|
|
@override_settings(SEND_MISSED_MESSAGE_EMAILS_AS_USER=True)
|
|
|
|
def test_deleted_message_in_missed_stream_messages_as_user(self):
|
|
|
|
# type: () -> None
|
|
|
|
self._deleted_message_in_missed_stream_messages(True)
|
|
|
|
|
|
|
|
def test_deleted_message_in_missed_stream_messages(self):
|
|
|
|
# type: () -> None
|
|
|
|
self._deleted_message_in_missed_stream_messages(False)
|
|
|
|
|
|
|
|
@override_settings(SEND_MISSED_MESSAGE_EMAILS_AS_USER=True)
|
|
|
|
def test_deleted_message_in_personal_missed_stream_messages_as_user(self):
|
|
|
|
# type: () -> None
|
|
|
|
self._deleted_message_in_personal_missed_stream_messages(True)
|
|
|
|
|
|
|
|
def test_deleted_message_in_personal_missed_stream_messages(self):
|
|
|
|
# type: () -> None
|
|
|
|
self._deleted_message_in_personal_missed_stream_messages(False)
|
|
|
|
|
|
|
|
@override_settings(SEND_MISSED_MESSAGE_EMAILS_AS_USER=True)
|
|
|
|
def test_deleted_message_in_huddle_missed_stream_messages_as_user(self):
|
|
|
|
# type: () -> None
|
|
|
|
self._deleted_message_in_huddle_missed_stream_messages(True)
|
|
|
|
|
|
|
|
def test_deleted_message_in_huddle_missed_stream_messages(self):
|
|
|
|
# type: () -> None
|
|
|
|
self._deleted_message_in_huddle_missed_stream_messages(False)
|
2017-07-07 22:34:22 +02:00
|
|
|
|
|
|
|
@patch('zerver.lib.email_mirror.generate_random_token')
|
|
|
|
def test_realm_emoji_in_missed_message(self, mock_random_token):
|
|
|
|
# type: (MagicMock) -> None
|
|
|
|
tokens = self._get_tokens()
|
|
|
|
mock_random_token.side_effect = tokens
|
|
|
|
|
|
|
|
msg_id = self.send_message(self.example_email('othello'), self.example_email('hamlet'),
|
|
|
|
Recipient.PERSONAL,
|
2017-07-18 00:14:23 +02:00
|
|
|
'Extremely personal message with a realm emoji :green_tick:!')
|
|
|
|
body = '<img alt=":green_tick:" height="20px" src="http://testserver/user_avatars/1/emoji/green_tick.png" title="green tick">'
|
2017-07-14 03:33:35 +02:00
|
|
|
subject = 'Othello, the Moor of Venice sent you a message'
|
2017-07-07 22:34:22 +02:00
|
|
|
self._test_cases(tokens, msg_id, body, subject, send_as_user=False, verify_html_body=True)
|
2017-07-15 01:07:52 +02:00
|
|
|
|
|
|
|
@patch('zerver.lib.email_mirror.generate_random_token')
|
|
|
|
def test_stream_link_in_missed_message(self, mock_random_token):
|
|
|
|
# type: (MagicMock) -> None
|
|
|
|
tokens = self._get_tokens()
|
|
|
|
mock_random_token.side_effect = tokens
|
|
|
|
|
|
|
|
msg_id = self.send_message(self.example_email('othello'), self.example_email('hamlet'),
|
|
|
|
Recipient.PERSONAL,
|
|
|
|
'Come and join us in #**Verona**.')
|
|
|
|
body = '<a class="stream" data-stream-id="5" href="http://testserver/#narrow/stream/Verona">#Verona</a'
|
|
|
|
subject = 'Othello, the Moor of Venice sent you a message'
|
|
|
|
self._test_cases(tokens, msg_id, body, subject, send_as_user=False, verify_html_body=True)
|