Skip to content
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

set default phone provider #2523

Merged
merged 10 commits into from
Jul 17, 2023
Merged
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Remove deprecated `heartbeat.HeartBeat` model/table by @joeyorlando ([#2534](https://github.com/grafana/oncall/pull/2534))

- Added `PHONE_PROVIDER` configuration check by @sreway ([#2523](https://github.com/grafana/oncall/pull/2523))
sreway marked this conversation as resolved.
Show resolved Hide resolved
joeyorlando marked this conversation as resolved.
Show resolved Hide resolved

## v1.3.12 (2023-07-14)

### Added
Expand Down
4 changes: 4 additions & 0 deletions engine/apps/phone_notifications/phone_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,4 +181,8 @@ def get_phone_provider() -> PhoneProvider:
if len(_providers) == 0:
for provider_alias, importpath in settings.PHONE_PROVIDERS.items():
_providers[provider_alias] = import_string(importpath)()

if live_settings.PHONE_PROVIDER not in settings.PHONE_PROVIDERS.keys():
return _providers[settings.DEFAULT_PHONE_PROVIDER]

return _providers[live_settings.PHONE_PROVIDER]
3 changes: 2 additions & 1 deletion engine/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,7 @@ class BrokerTypes:

# map of phone provider alias to importpath.
# Used in get_phone_provider function to dynamically load current provider.
DEFAULT_PHONE_PROVIDER = "twilio"
PHONE_PROVIDERS = {
"twilio": "apps.twilioapp.phone_provider.TwilioPhoneProvider",
# "simple": "apps.phone_notifications.simple_phone_provider.SimplePhoneProvider",
Expand All @@ -733,7 +734,7 @@ class BrokerTypes:
if IS_OPEN_SOURCE:
PHONE_PROVIDERS["zvonok"] = "apps.zvonok.phone_provider.ZvonokPhoneProvider"

PHONE_PROVIDER = os.environ.get("PHONE_PROVIDER", default="twilio")
PHONE_PROVIDER = os.environ.get("PHONE_PROVIDER", default=DEFAULT_PHONE_PROVIDER)

ZVONOK_API_KEY = os.getenv("ZVONOK_API_KEY", None)
ZVONOK_CAMPAIGN_ID = os.getenv("ZVONOK_CAMPAIGN_ID", None)
Expand Down