Skip to content

Commit

Permalink
set default phone provider (#2523)
Browse files Browse the repository at this point in the history
# What this PR does

Sets a default value for the PHONE_PROVIDER setting and replaces the
value of PHONE_PROVIDER with this default value if it is not valid.

## Which issue(s) this PR fixes

- [#2520](#2520)
- [#2323](#2323)

## Checklist

- [ ] Unit, integration, and e2e (if applicable) tests updated
- [ ] Documentation added (or `pr:no public docs` PR label added if not
required)
- [ ] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)

---------

Co-authored-by: Innokentii Konstantinov <innokenty.konstantinov@grafana.com>
Co-authored-by: Joey Orlando <joseph.t.orlando@gmail.com>
Co-authored-by: Joey Orlando <joey.orlando@grafana.com>
  • Loading branch information
4 people authored Jul 17, 2023
1 parent cae8387 commit 8644883
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

### Changed

- Added `PHONE_PROVIDER` configuration check by @sreway ([#2523](https://github.com/grafana/oncall/pull/2523))

## v1.3.13 (2023-07-17)

### Changed
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

0 comments on commit 8644883

Please sign in to comment.