From 88b8a4168fe7a6e2478cad47fb5ae0c6e2f86bc7 Mon Sep 17 00:00:00 2001 From: Piotr Gawron <piotr.gawron@uni.lu> Date: Mon, 25 Jan 2021 15:38:58 +0100 Subject: [PATCH] don't allow for empty NEXMO_FROM --- CHANGELOG | 3 +++ .../migrations/0176_configurationitem_local_setting_clean.py | 2 ++ smash/web/nexmo_gateway.py | 2 ++ 3 files changed, 7 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 1953dd3d..00b32f68 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,9 @@ smasch (1.0.0~beta.3-1) unstable; urgency=low * bug fix: upgrade from 0.15 version containing subjects failed + * bug fix: language import was not allowed + * bug fix: empty NEXMO_DEFAULT_FROM did not allow to send authentication + tokens using NEXMO (#364) -- Piotr Gawron <piotr.gawron@uni.lu> Tue, 12 Jan 2021 10:00:00 +0200 diff --git a/smash/web/migrations/0176_configurationitem_local_setting_clean.py b/smash/web/migrations/0176_configurationitem_local_setting_clean.py index b2506ca5..b9289a0d 100644 --- a/smash/web/migrations/0176_configurationitem_local_setting_clean.py +++ b/smash/web/migrations/0176_configurationitem_local_setting_clean.py @@ -66,6 +66,8 @@ def configuration_items(apps, schema_editor): create_item(apps, NEXMO_API_SECRET, nexmo_api_secret, "NEXMO API SECRET") nexmo_api_from = getattr(settings, 'NEXMO_DEFAULT_FROM', '') + if nexmo_api_from is None or nexmo_api_from == "": + nexmo_api_from = "SMASCH" create_item(apps, NEXMO_DEFAULT_FROM, nexmo_api_from, "The sender of the message from NEXMO (phone number or text)") background_image = getattr(settings, "LOGIN_PAGE_BACKGROUND_IMAGE", "background.jpg") diff --git a/smash/web/nexmo_gateway.py b/smash/web/nexmo_gateway.py index 41916392..70a116f4 100644 --- a/smash/web/nexmo_gateway.py +++ b/smash/web/nexmo_gateway.py @@ -32,6 +32,8 @@ class Nexmo: api_secret = ConfigurationItem.objects.get(type=NEXMO_API_SECRET).value self.client = nexmo.Client(key=api_key, secret=api_secret) self.default_from = ConfigurationItem.objects.get(type=NEXMO_DEFAULT_FROM).value + if self.default_from is None or self.default_from == "": + self.default_from = "SMASCH" def send_sms(self, device, token): body = 'Your authentication token is %s' % token -- GitLab