mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 23:55:58 -05:00
Only use service sender value if it is valid for SNS OriginationNumber
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import re
|
||||||
from time import monotonic
|
from time import monotonic
|
||||||
|
|
||||||
import botocore
|
import botocore
|
||||||
@@ -23,6 +24,7 @@ class AwsSnsClient(SmsClient):
|
|||||||
super(SmsClient, self).__init__(*args, **kwargs)
|
super(SmsClient, self).__init__(*args, **kwargs)
|
||||||
self.current_app = current_app
|
self.current_app = current_app
|
||||||
self.statsd_client = statsd_client
|
self.statsd_client = statsd_client
|
||||||
|
self._valid_sender_regex = re.compile(r"^\+?\d{5,14}$")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
@@ -31,6 +33,9 @@ class AwsSnsClient(SmsClient):
|
|||||||
def get_name(self):
|
def get_name(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
|
def _valid_sender_number(self, sender):
|
||||||
|
return sender and re.match(self._valid_sender_regex, sender)
|
||||||
|
|
||||||
def send_sms(self, to, content, reference, sender=None, international=False):
|
def send_sms(self, to, content, reference, sender=None, international=False):
|
||||||
matched = False
|
matched = False
|
||||||
|
|
||||||
@@ -47,7 +52,7 @@ class AwsSnsClient(SmsClient):
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if sender:
|
if self._valid_sender_number(sender):
|
||||||
attributes["AWS.MM.SMS.OriginationNumber"] = {
|
attributes["AWS.MM.SMS.OriginationNumber"] = {
|
||||||
"DataType": "String",
|
"DataType": "String",
|
||||||
"StringValue": sender,
|
"StringValue": sender,
|
||||||
|
|||||||
Reference in New Issue
Block a user