Skip to content

Commit

Permalink
do not call services if not needed
Browse files Browse the repository at this point in the history
  • Loading branch information
KlemenSpruk committed Oct 25, 2023
1 parent 861815c commit 6268d95
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ def enqueue_dlr_request(self, pk: str):
DeliveryReport.objects.filter(pk=pk).update(status=DeliveryReport.Status.DELIVERED)

def client_send(self, sender: str, recipient: Recipient, msg: dict, dlr_id: str):
if not recipient.email:
return
res = (
boto3.Session(
aws_access_key_id=self.key_id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ def validate_send(self, response: dict):
assert is_success(response.get("ResponseMetadata", {}).get("HTTPStatusCode", 500))

def client_send(self, sender: str, recipient: Recipient, msg: str, dlr_id: str):
if not recipient.phone_number:
return
smsattrs = {
"AWS.SNS.SMS.SenderID": {"DataType": "String", "StringValue": sender.replace(" ", "-")},
"AWS.SNS.SMS.SMSType": {"DataType": "String", "StringValue": "Promotional"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ def client_send(self, sender: str, recipient: Recipient, msg: str, dlr_id: str):
if not rec:
return

if not rec[0]:
return

params: dict = {
"api_key": self.api_key,
"api_secret": self.api_secret,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,8 @@ def ensure_credentials(self, extra_data):
assert len(self.url) > 0, "T2_PASSWORD is required"

def client_send(self, sender: str, recipient: Recipient, msg: str, dlr_id: str):
if not recipient.phone_number:
return
basic_auth = HTTPBasicAuth(self.username, self.password)
response = requests.post(
f"{self.url}{self.endpoint_one}",
Expand Down

0 comments on commit 6268d95

Please sign in to comment.