Skip to content

Commit

Permalink
sns_topic: Allow canonical international-format phone numbers in SMS …
Browse files Browse the repository at this point in the history
…subscriptions (ansible-collections#454)

* Update sns_topic.py

Adds `+` to the list of acceptable characters in an SMS endpoint.

Closes ansible-collections#453.

* Add changelog fragment for ansible-collections#454

* sns_topic: comment explaining SMS canonicalization

Add comment documenting to what standard SMS endpoint addresses (phone
numbers) are canonicalized

* sns_topic: fix changelog

* Get quoting correct
* Simplify message to leave details in PR description

Co-authored-by: Mark Chappell <mchappel@redhat.com>

Co-authored-by: Mark Chappell <mchappel@redhat.com>
  • Loading branch information
overhacked and tremble authored Mar 8, 2021
1 parent d7659ec commit 72b0421
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion sns_topic.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,11 @@ def _set_topic_attrs(self):
return changed

def _canonicalize_endpoint(self, protocol, endpoint):
# AWS SNS expects phone numbers in
# and canonicalizes to E.164 format
# See <https://docs.aws.amazon.com/sns/latest/dg/sms_publish-to-phone.html>
if protocol == 'sms':
return re.sub('[^0-9]*', '', endpoint)
return re.sub('[^0-9+]*', '', endpoint)
return endpoint

def _set_topic_subs(self):
Expand Down

0 comments on commit 72b0421

Please sign in to comment.