mirror of https://github.com/zulip/zulip.git
scheduled_messages: Store the final delivered message ID.
This could be useful for debugging problems with the system operationally.
This commit is contained in:
parent
fe9656237e
commit
835f62617e
|
@ -230,10 +230,10 @@ def send_scheduled_message(scheduled_message: ScheduledMessage) -> None:
|
||||||
scheduled_message.realm,
|
scheduled_message.realm,
|
||||||
)
|
)
|
||||||
|
|
||||||
# TODO: Store the resulting message ID on the scheduled_message object.
|
message_id = do_send_messages([send_request])[0]
|
||||||
do_send_messages([send_request])
|
scheduled_message.delivered_message_id = message_id
|
||||||
scheduled_message.delivered = True
|
scheduled_message.delivered = True
|
||||||
scheduled_message.save(update_fields=["delivered"])
|
scheduled_message.save(update_fields=["delivered", "delivered_message_id"])
|
||||||
notify_remove_scheduled_message(scheduled_message.sender, scheduled_message.id)
|
notify_remove_scheduled_message(scheduled_message.sender, scheduled_message.id)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
# Generated by Django 4.2 on 2023-05-05 00:18
|
# Generated by Django 4.2 on 2023-05-05 00:18
|
||||||
|
|
||||||
|
import django.db.models.deletion
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
@ -19,4 +20,11 @@ class Migration(migrations.Migration):
|
||||||
name="failure_message",
|
name="failure_message",
|
||||||
field=models.TextField(null=True),
|
field=models.TextField(null=True),
|
||||||
),
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name="scheduledmessage",
|
||||||
|
name="delivered_message",
|
||||||
|
field=models.ForeignKey(
|
||||||
|
null=True, on_delete=django.db.models.deletion.CASCADE, to="zerver.message"
|
||||||
|
),
|
||||||
|
),
|
||||||
]
|
]
|
||||||
|
|
|
@ -4325,6 +4325,7 @@ class ScheduledMessage(models.Model):
|
||||||
realm = models.ForeignKey(Realm, on_delete=CASCADE)
|
realm = models.ForeignKey(Realm, on_delete=CASCADE)
|
||||||
scheduled_timestamp = models.DateTimeField(db_index=True)
|
scheduled_timestamp = models.DateTimeField(db_index=True)
|
||||||
delivered = models.BooleanField(default=False)
|
delivered = models.BooleanField(default=False)
|
||||||
|
delivered_message = models.ForeignKey(Message, null=True, on_delete=CASCADE)
|
||||||
has_attachment = models.BooleanField(default=False, db_index=True)
|
has_attachment = models.BooleanField(default=False, db_index=True)
|
||||||
|
|
||||||
# Metadata for messages that failed to send when their scheduled
|
# Metadata for messages that failed to send when their scheduled
|
||||||
|
|
|
@ -1073,7 +1073,7 @@ class TestDoDeleteMessages(ZulipTestCase):
|
||||||
message_ids = [self.send_stream_message(cordelia, "Verona", str(i)) for i in range(0, 10)]
|
message_ids = [self.send_stream_message(cordelia, "Verona", str(i)) for i in range(0, 10)]
|
||||||
messages = Message.objects.filter(id__in=message_ids)
|
messages = Message.objects.filter(id__in=message_ids)
|
||||||
|
|
||||||
with self.assert_database_query_count(19):
|
with self.assert_database_query_count(20):
|
||||||
do_delete_messages(realm, messages)
|
do_delete_messages(realm, messages)
|
||||||
self.assertFalse(Message.objects.filter(id__in=message_ids).exists())
|
self.assertFalse(Message.objects.filter(id__in=message_ids).exists())
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue