Skip to content

Commit a6f5b45

Browse files
authored
add UnsubscribeURL in payload sent to HTTP SQS endpoints (localstack#4058)
1 parent c004dca commit a6f5b45

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

localstack/services/sns/sns_listener.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,8 +314,10 @@ def message_to_subscribers(message_id, message, topic_arn, req_data, headers, su
314314

315315
elif subscriber['Protocol'] == 'sqs':
316316
queue_url = None
317+
317318
try:
318319
endpoint = subscriber['Endpoint']
320+
319321
if 'sqs_queue_url' in subscriber:
320322
queue_url = subscriber.get('sqs_queue_url')
321323
elif '://' in endpoint:
@@ -482,6 +484,7 @@ def do_subscribe(topic_arn, endpoint, protocol, subscription_arn, attributes, fi
482484
if protocol in ['http', 'https']:
483485
token = short_uid()
484486
external_url = external_service_url('sns')
487+
subscription['UnsubscribeURL'] = '%s/?Action=Unsubscribe&SubscriptionArn=%s' % (external_url, subscription_arn)
485488
confirmation = {
486489
'Type': ['SubscriptionConfirmation'],
487490
'Token': [token],
@@ -620,6 +623,10 @@ def create_sns_message_body(subscriber, req_data, message_id=None):
620623
if req_data.get(key):
621624
data[key] = req_data[key][0]
622625

626+
for key in ['UnsubscribeURL']:
627+
if key in subscriber:
628+
data[key] = subscriber[key]
629+
623630
attributes = get_message_attributes(req_data)
624631
if attributes:
625632
data['MessageAttributes'] = attributes

0 commit comments

Comments
 (0)