mirror of https://github.com/zulip/zulip.git
models: Allow scheduled msgs to store rendered content.
This is required by the client to display a list of currently scheduled messages.
This commit is contained in:
parent
a941545523
commit
b63f440fb1
|
@ -467,7 +467,11 @@ def do_schedule_messages(send_message_requests: Sequence[SendMessageRequest]) ->
|
|||
scheduled_message.recipient = send_request.message.recipient
|
||||
topic_name = send_request.message.topic_name()
|
||||
scheduled_message.set_topic_name(topic_name=topic_name)
|
||||
rendering_result = render_markdown(
|
||||
send_request.message, send_request.message.content, send_request.realm
|
||||
)
|
||||
scheduled_message.content = send_request.message.content
|
||||
scheduled_message.rendered_content = rendering_result.rendered_content
|
||||
scheduled_message.sending_client = send_request.message.sending_client
|
||||
scheduled_message.stream = send_request.stream
|
||||
scheduled_message.realm = send_request.realm
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
# Generated by Django 4.1.5 on 2023-01-16 08:35
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
("zerver", "0434_create_nobody_system_group"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="scheduledmessage",
|
||||
name="rendered_content",
|
||||
field=models.TextField(default=""),
|
||||
preserve_default=False,
|
||||
),
|
||||
]
|
|
@ -4326,6 +4326,7 @@ class ScheduledMessage(models.Model):
|
|||
recipient = models.ForeignKey(Recipient, on_delete=CASCADE)
|
||||
subject = models.CharField(max_length=MAX_TOPIC_NAME_LENGTH)
|
||||
content = models.TextField()
|
||||
rendered_content = models.TextField()
|
||||
sending_client = models.ForeignKey(Client, on_delete=CASCADE)
|
||||
stream = models.ForeignKey(Stream, null=True, on_delete=CASCADE)
|
||||
realm = models.ForeignKey(Realm, on_delete=CASCADE)
|
||||
|
|
|
@ -1385,6 +1385,7 @@ class ScheduledMessageTest(ZulipTestCase):
|
|||
message = self.last_scheduled_message()
|
||||
self.assert_json_success(result)
|
||||
self.assertEqual(message.content, "Test message 1")
|
||||
self.assertEqual(message.rendered_content, "<p>Test message 1</p>")
|
||||
self.assertEqual(message.topic_name(), "Test topic")
|
||||
self.assertEqual(message.scheduled_timestamp, convert_to_UTC(defer_until))
|
||||
self.assertEqual(message.delivery_type, ScheduledMessage.SEND_LATER)
|
||||
|
@ -1405,6 +1406,7 @@ class ScheduledMessageTest(ZulipTestCase):
|
|||
message = self.last_scheduled_message()
|
||||
self.assert_json_success(result)
|
||||
self.assertEqual(message.content, "Test message 3")
|
||||
self.assertEqual(message.rendered_content, "<p>Test message 3</p>")
|
||||
self.assertEqual(message.scheduled_timestamp, convert_to_UTC(defer_until))
|
||||
self.assertEqual(message.delivery_type, ScheduledMessage.SEND_LATER)
|
||||
|
||||
|
|
Loading…
Reference in New Issue