-
Notifications
You must be signed in to change notification settings - Fork 337
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add support for configurable sms backend #2024
add support for configurable sms backend #2024
Conversation
@sainak ptal, shoud i add tests for other places as well ? |
Pipfile
Outdated
@@ -45,6 +45,7 @@ requests = "==2.31.0" | |||
sentry-sdk = "==1.30.0" | |||
whitenoise = "==6.5.0" | |||
redis-om = "==0.2.1" | |||
django-sms = "*" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pin to a specific version
care/utils/sms/sendSMS.py
Outdated
|
||
class CustomSMSBackendSNS(BaseSmsBackend): | ||
def send_messages(self, messages: List[Message]): | ||
client = boto3.client( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
initialize the client in __init__()
care/utils/sms/sendSMS.py
Outdated
except Exception: | ||
continue | ||
|
||
client.publish(PhoneNumber=phone_number, Message=message_body) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
handle exceptions
config/settings/local.py
Outdated
@@ -48,3 +48,5 @@ | |||
RUNSERVER_PLUS_PRINT_SQL_TRUNCATE = 100000 | |||
|
|||
DISABLE_RATELIMIT = True | |||
|
|||
SMS_BACKEND = "care.utils.sms.sendSMS.CustomSMSBackendSNS" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
set SMS_BACKEND = "care.utils.sms.sendSMS.CustomSMSBackendSNS"
in base settings
and for local and test use console backend
@vigneshhari though the django-sms provides a standard wrapper for sms, the backend themselves have different names for settings, and some backends require client sdks to be installed |
@sainak let me know if the changes made look good to you |
Hey @AnkurPrabhu thanks for these changes, but we are planning to move the sms backends to a plugin system, once the plugin architecture becomes stable, we will create our own implementation for the sms cc: @vigneshhari |
Proposed Changes
Associated Issue
Merge Checklist
/docs
Only PR's with test cases included and passing lint and test pipelines will be reviewed
@coronasafe/care-backend-maintainers @coronasafe/care-backend-admins