Fix cancel broadcast by converting reference date to string

Datetime oobject is not json serializable, we have to convert
it to string for the created_at field of previous broadcast
provider messages.
This commit is contained in:
Pea Tyczynska
2020-12-18 17:22:11 +00:00
parent 519568970c
commit ee833bd65b
2 changed files with 26 additions and 14 deletions

View File

@@ -165,12 +165,16 @@ class CBCProxyEE(CBCProxyClientBase):
identifier, previous_provider_messages,
sent, message_number=None
):
from app import DATETIME_FORMAT
payload = {
'message_type': 'cancel',
'identifier': identifier,
'message_format': 'cap',
"references": [
{"message_id": str(message.id), "sent": message.created_at} for message in previous_provider_messages
{
"message_id": str(message.id),
"sent": message.created_at.strftime(DATETIME_FORMAT)
} for message in previous_provider_messages
],
'sent': sent,
}
@@ -219,6 +223,7 @@ class CBCProxyVodafone(CBCProxyClientBase):
):
# avoid cyclical import
from app.utils import format_sequential_number
from app import DATETIME_FORMAT
payload = {
'message_type': 'cancel',
@@ -229,7 +234,7 @@ class CBCProxyVodafone(CBCProxyClientBase):
{
"message_id": str(message.id),
"message_number": format_sequential_number(message.message_number),
"sent": message.created_at
"sent": message.created_at.strftime(DATETIME_FORMAT)
} for message in previous_provider_messages
],
'sent': sent,