From 2c5b5fce60662daf61b88fefb10c628e29e690aa Mon Sep 17 00:00:00 2001 From: Cal Ellowitz Date: Thu, 12 Dec 2024 22:38:58 -0500 Subject: [PATCH] set message id on init --- corehq/apps/sms/models.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/corehq/apps/sms/models.py b/corehq/apps/sms/models.py index c464543de008..071e93cadd90 100644 --- a/corehq/apps/sms/models.py +++ b/corehq/apps/sms/models.py @@ -2766,6 +2766,12 @@ class ConnectMessage(Log): received_on = models.DateTimeField(null=True, blank=True) message_id = models.UUIDField(default=uuid4) + def __init__(self, *args, **kwargs): + # set default message id on initialization so it is available before save + super(ConnectMessage, self).__init__(*args, **kwargs) + if self.message_id is None: + self.message_id = uuid4() + @property def outbound_backend(self): return ConnectBackend()