Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

reminders: Pick the quote fence from the quoted message's content.

Aman Agrawal993b207cd393
diff --git a/zerver/lib/reminders.py b/zerver/lib/reminders.py
index 642152bb50e..8e26eaa0eba 100644
--- a/zerver/lib/reminders.py
+++ b/zerver/lib/reminders.py
@@ -151,7 +151,7 @@ def get_reminder_formatted_content(
else:
content += REMINDER_FORMAT[format_recipient_type_key]["text"].format_map(context)
content += "\n"
- fence = get_unused_fence(content)
+ fence = get_unused_fence(message.content)
quoted_message = "{fence}quote\n{msg_content}\n{fence}"
length_without_message_content = len(
content + quoted_message.format(fence=fence, msg_content="")
diff --git a/zerver/tests/test_reminders.py b/zerver/tests/test_reminders.py
index 8c47b7afb66..3bda9998190 100644
--- a/zerver/tests/test_reminders.py
+++ b/zerver/tests/test_reminders.py
@@ -640,6 +640,34 @@ class RemindersTest(ZulipTestCase):
f"```quote\n{content}\n```",
)
+ def test_reminder_for_message_with_code_block(self) -> None:
+ content = "Look at this:\n```\nprint('hello')\n```\nDoes it work?"
+ message_id = self.send_channel_message_for_hamlet(content)
+ result = self.do_schedule_reminder(message_id, int(time.time() + 86400))
+ self.assert_json_success(result)
+ scheduled_message = self.last_scheduled_reminder()
+
+ self.assertEqual(
+ scheduled_message.content,
+ f"""
+You requested a reminder for the following message.
+
+@_**King Hamlet|10** [said](http://zulip.testserver/#narrow/channel/3-Verona/topic/test/near/{message_id}) in [#Verona > test](#narrow/channel/3-Verona/topic/test/with/{message_id}):
+````quote
+Look at this:
+```
+print('hello')
+```
+Does it work?
+````
+""".strip(),
+ )
+ self.assertIn(
+ '<blockquote>\n<p>Look at this:</p>\n<div class="codehilite"',
+ scheduled_message.rendered_content,
+ )
+ self.assertIn("<p>Does it work?</p>\n</blockquote>", scheduled_message.rendered_content)
+
def test_schedule_reminder_ones_own_message(self) -> None:
content = "Test message"
scheduled_delivery_timestamp = int(time.time() + 86400)