From 07583f0c3b1f12661ef138c052ef3b4afb6a2118 Mon Sep 17 00:00:00 2001 From: Philip Wafula Date: Wed, 23 Jun 2021 07:02:22 +0000 Subject: [PATCH] Handle empty string defaults in kubernetes secrets. --- apps/cic-notify/cic_notify/runnable/tasker.py | 10 +++++++++- apps/cic-ussd/cic_ussd/phone_number.py | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/apps/cic-notify/cic_notify/runnable/tasker.py b/apps/cic-notify/cic_notify/runnable/tasker.py index 453044f0..90417c7e 100644 --- a/apps/cic-notify/cic_notify/runnable/tasker.py +++ b/apps/cic-notify/cic_notify/runnable/tasker.py @@ -87,10 +87,18 @@ for key in config.store.keys(): module = importlib.import_module(config.store[key]) if key == 'TASKS_AFRICASTALKING': africastalking_notifier = module.AfricasTalkingNotifier + + api_sender_id = config.get('AFRICASTALKING_API_SENDER_ID') + logg.debug(f'SENDER ID VALUE IS: {api_sender_id}') + + if not api_sender_id: + api_sender_id = None + logg.debug(f'SENDER ID RESOLVED TO NONE: {api_sender_id}') + africastalking_notifier.initialize( config.get('AFRICASTALKING_API_USERNAME'), config.get('AFRICASTALKING_API_KEY'), - config.get('AFRICASTALKING_API_SENDER_ID') + api_sender_id ) diff --git a/apps/cic-ussd/cic_ussd/phone_number.py b/apps/cic-ussd/cic_ussd/phone_number.py index 2c476fa0..f3bdfde6 100644 --- a/apps/cic-ussd/cic_ussd/phone_number.py +++ b/apps/cic-ussd/cic_ussd/phone_number.py @@ -38,7 +38,7 @@ def get_user_by_phone_number(phone_number: str) -> Optional[Account]: :rtype: Account|None """ # consider adding region to user's metadata - phone_number = process_phone_number(phone_number=phone_number, region='KE') + phone_number = process_phone_number(phone_number=phone_number, region=E164Format.region) user = Account.session.query(Account).filter_by(phone_number=phone_number).first() return user