-
Notifications
You must be signed in to change notification settings - Fork 1
/
send_result_activity.py
31 lines (25 loc) · 976 Bytes
/
send_result_activity.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#
# **SendResultActivity** sends the result of the activity to the screen, and, if
# the user successfully registered using SNS, to the user using the SNS contact
# information collected.
#
import json
from basic_activity import BasicActivity
import boto3
class SendResultActivity(BasicActivity):
# initialize the activity
def __init__(self):
super(SendResultActivity, self).__init__('SendResultActivity', 'v1')
# confirm the SNS topic subscription
def do_activity(self, task):
if task:
subscription_data = json.loads(task["input"])
else:
self.results = json.dumps({"reason", "Didn't receive any input!", "detail", "" })
return
sns_client = boto3.client('sns')
results = "Thanks, you've successfully confirmed registration, and your workflow is complete!"
# send the message via SNS
sns_client.publish(TopicArn=subscription_data["topic_arn"], Message=results)
self.results=results
return True