diff --git a/zerver/lib/notifications.py b/zerver/lib/notifications.py
index d677345dcc..a8d200a392 100644
--- a/zerver/lib/notifications.py
+++ b/zerver/lib/notifications.py
@@ -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):
diff --git a/zerver/tests/test_notifications.py b/zerver/tests/test_notifications.py
index 6f9e7ad201..6f05005e60 100644
--- a/zerver/tests/test_notifications.py
+++ b/zerver/tests/test_notifications.py
@@ -349,3 +349,16 @@ class TestMissedMessages(ZulipTestCase):
body = '
'
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 = '#Verona