Skip to content

Commit

Permalink
Fix context handling to move routing_key to mq context (#49)
Browse files Browse the repository at this point in the history
Co-authored-by: Daniel McKnight <[email protected]>
  • Loading branch information
NeonDaniel and NeonDaniel authored Nov 18, 2023
1 parent 49e2afc commit ea1449f
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions neon_messagebus_mq_connector/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,16 +129,15 @@ def handle_neon_message(self, message: Message):
if not message.data:
message.data['msg'] = 'Failed to get response from Neon'
message.context.setdefault('klat_data', {})
message.context.setdefault('mq', {})
if message.msg_type == 'neon.get_tts.response':
body = self.format_response(response_type=NeonResponseTypes.TTS,
message=message)
message.context['klat_data'].setdefault('routing_key',
'neon_tts_response')
message.context['mq'].setdefault('routing_key', 'neon_tts_response')
elif message.msg_type == 'neon.get_stt.response':
body = self.format_response(response_type=NeonResponseTypes.STT,
message=message)
message.context['klat_data'].setdefault('routing_key',
'neon_stt_response')
message.context['mq'].setdefault('routing_key', 'neon_stt_response')
else:
body = {'msg_type': message.msg_type,
'data': message.data, 'context': message.context}
Expand Down Expand Up @@ -168,7 +167,7 @@ def handle_neon_profile_update(self, message: Message):
to avoid publishing private profile values to a shared queue
:param message: Message containing the updated user profile
"""
if message.context.get('klat_data', {}).get('routing_key'):
if message.context.get('mq', {}).get('routing_key'):
LOG.info(f"handling profile update for "
f"user={message.data['profile']['user']['username']}")
self.handle_neon_message(message)
Expand Down

0 comments on commit ea1449f

Please sign in to comment.