Skip to content

Commit

Permalink
throw unconfigured alert if no API key
Browse files Browse the repository at this point in the history
  • Loading branch information
jchate6 committed Dec 15, 2023
1 parent d9bbb98 commit bd3acba
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions tom_tns/tns_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,15 @@ def get_tns_credentials():
"""
try:
tns_info = settings.BROKERS['TNS']
# Build TNS Marker using Bot info
tns_info['marker'] = 'tns_marker' + json.dumps({'tns_id': tns_info.get('bot_id', None),
'type': 'bot',
'name': tns_info.get('bot_name', None)})

# Build TNS Marker using Bot info if API key is present
if tns_info.get('api_key', None):
tns_info['marker'] = 'tns_marker' + json.dumps({'tns_id': tns_info.get('bot_id', None),
'type': 'bot',
'name': tns_info.get('bot_name', None)})
else:
logger.error("TNS API key not found in settings.py")
tns_info = {}
except (KeyError, AttributeError):
logger.error("TNS credentials not found in settings.py")
tns_info = {}
Expand Down

0 comments on commit bd3acba

Please sign in to comment.