notifications: Fix relative stream links in missed message emails.

Fixes: #5310.
This commit is contained in:
Harshit Bansal 2017-07-14 23:07:52 +00:00
parent 1731da30da
commit 45bc220796
2 changed files with 20 additions and 0 deletions

View File

@ -119,6 +119,13 @@ def build_message_list(user_profile, messages):
r"/user_avatars/(\d+)/emoji/",
user_profile.realm.uri + r"/user_avatars/\1/emoji/", content)
# Stream links need to be converted from relative to absolute. They
# have href values in the form of "/#narrow/stream/...".
content = re.sub(
r"/#narrow/stream/",
user_profile.realm.uri + r"/#narrow/stream/",
content)
return content
def fix_plaintext_image_urls(content):

View File

@ -349,3 +349,16 @@ class TestMissedMessages(ZulipTestCase):
body = '<img alt=":test_emoji:" height="20px" src="http://testserver/user_avatars/1/emoji/test_emoji.png" title=":test_emoji:">'
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)
@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)