Sqs queues now populated from all create_notification api calls. Marshmallow schemas added for notification.

This commit is contained in:
Nicholas Staples
2016-02-03 13:16:19 +00:00
parent 02a38572bb
commit aba1cd2ed5
7 changed files with 184 additions and 161 deletions

18
app/aws_sqs.py Normal file
View File

@@ -0,0 +1,18 @@
import uuid
import boto3
from itsdangerous import URLSafeSerializer
from flask import current_app
def add_notification_to_queue(service_id, template_id, type_, notification):
q = boto3.resource(
'sqs', region_name=current_app.config['AWS_REGION']
).create_queue(QueueName=str(service_id))
message_id = str(uuid.uuid4())
serializer = URLSafeSerializer(current_app.config.get('SECRET_KEY'))
encrypted = serializer.dumps(notification, current_app.config.get('DANGEROUS_SALT'))
q.send_message(MessageBody=encrypted,
MessageAttributes={'type': {'StringValue': type_, 'DataType': 'String'},
'message_id': {'StringValue': message_id, 'DataType': 'String'},
'service_id': {'StringValue': str(service_id), 'DataType': 'String'},
'template_id': {'StringValue': str(template_id), 'DataType': 'String'}})