Skip to content

Commit

Permalink
sending with pinpoint pool
Browse files Browse the repository at this point in the history
  • Loading branch information
sastels committed Apr 9, 2024
1 parent 064e36d commit b9d0d3a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
11 changes: 4 additions & 7 deletions app/clients/sms/aws_pinpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ class AwsPinpointClient(SmsClient):

def init_app(self, current_app, statsd_client, *args, **kwargs):
self._client = boto3.client('pinpoint-sms-voice-v2', region_name="ca-central-1")
super(SmsClient, self).__init__(*args, **kwargs)
super(AwsPinpointClient, self).__init__(*args, **kwargs)
# super(SmsClient, self).__init__(*args, **kwargs)
self.current_app = current_app
self.name = 'pinpoint'
self.statsd_client = statsd_client
Expand Down Expand Up @@ -41,10 +42,6 @@ def send_sms(self, to, content, reference, multi=True, sender=None):
MessageType=messageType,
)

# this will be true if the OriginationIdentity does not exist in pinpoint
if response['MessageResponse']['Result'][destinationNumber]['StatusCode'] == 400:
self.statsd_client.incr("clients.pinpoint.error")
raise Exception(response['MessageResponse']['Result'][destinationNumber]['StatusMessage'])
except ClientError as e:
self.statsd_client.incr("clients.pinpoint.error")
raise Exception(e)
Expand All @@ -57,9 +54,9 @@ def send_sms(self, to, content, reference, multi=True, sender=None):
self.statsd_client.timing("clients.pinpoint.request-time", elapsed_time)
self.statsd_client.incr("clients.pinpoint.success")

return response['MessageResponse']['Result'][destinationNumber]['MessageId']
return response['MessageId']

if not matched:
self.statsd_client.incr("clients.pinpoint.error")
self.current_app.logger.error("No valid numbers found in {}".format(to))
raise ValueError("No valid numbers found for SMS delivery")
raise ValueError("No valid numbers found for SMS delivery")
2 changes: 0 additions & 2 deletions app/delivery/send_to_providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ def send_sms_to_provider(notification):
notification.international,
notification.reply_to_text,
)



template_dict = dao_get_template_by_id(notification.template_id, notification.template_version).__dict__

Expand Down

0 comments on commit b9d0d3a

Please sign in to comment.