mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-01 20:28:44 -04:00
add send_broadcast_message task
task takes a brodcast_message_id, and makes a post to the cbc-proxy for now, hardcode the url to the notify stub. the stub requires template as the admin/api get it, so use the marshmallow schema to json dump it. Note - this also required us to tweak the BroadcastMessage.serialize function so that it converts uuids in to ids - flask's jsonify function does that for free but requests.post doesn't sadly. if the request fails (either 4xx or 5xx) just raise an exception and let it bubble up for now - in the future we'll add retry logic
This commit is contained in:
@@ -2224,11 +2224,11 @@ class BroadcastMessage(db.Model):
|
||||
|
||||
def serialize(self):
|
||||
return {
|
||||
'id': self.id,
|
||||
'id': str(self.id),
|
||||
|
||||
'service_id': self.service_id,
|
||||
'service_id': str(self.service_id),
|
||||
|
||||
'template_id': self.template_id,
|
||||
'template_id': str(self.template_id),
|
||||
'template_version': self.template_version,
|
||||
'template_name': self.template.name,
|
||||
|
||||
@@ -2245,7 +2245,7 @@ class BroadcastMessage(db.Model):
|
||||
'cancelled_at': self.cancelled_at.strftime(DATETIME_FORMAT) if self.cancelled_at else None,
|
||||
'updated_at': self.updated_at.strftime(DATETIME_FORMAT) if self.updated_at else None,
|
||||
|
||||
'created_by_id': self.created_by_id,
|
||||
'approved_by_id': self.approved_by_id,
|
||||
'cancelled_by_id': self.cancelled_by_id,
|
||||
'created_by_id': str(self.created_by_id),
|
||||
'approved_by_id': str(self.approved_by_id),
|
||||
'cancelled_by_id': str(self.cancelled_by_id),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user