Skip to content

Commit

Permalink
fixed issue with translation request
Browse files Browse the repository at this point in the history
  • Loading branch information
kirgrim committed Apr 28, 2024
1 parent e31af2a commit 93074c9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion chat_server/sio/handlers/translation.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,10 @@ async def request_translate(sid, data):
LOG.warning("Missing request translate data, skipping...")
else:
input_type = data.get("inputType", "incoming")
user_id = data.get("user")

populated_translations, missing_translations = mongo_queries.get_translations(
translation_mapping=data.get("chat_mapping", {})
translation_mapping=data.get("chat_mapping", {}), requested_user_id=user_id
)
if populated_translations and not missing_translations:
await sio.emit(
Expand Down
7 changes: 5 additions & 2 deletions utils/database_utils/mongo_utils/queries/mongo_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,14 @@
from utils.logging_utils import LOG


def get_translations(translation_mapping: dict) -> Tuple[dict, dict]:
def get_translations(
translation_mapping: dict, requested_user_id: str
) -> Tuple[dict, dict]:
"""
Gets translation from db based on provided mapping
:param translation_mapping: mapping of cid to desired translation language
:param requested_user_id: id of requested user
:return translations fetched from db
"""
Expand All @@ -48,7 +51,7 @@ def get_translations(translation_mapping: dict) -> Tuple[dict, dict]:
lang = cid_data.get("lang", "en")
shout_ids = cid_data.get("shouts", [])
conversation_data = MongoDocumentsAPI.CHATS.get_chat(
search_str=cid, include_private=True
search_str=cid, requested_user_id=requested_user_id
)
if not conversation_data:
LOG.error(f"Failed to fetch conversation data - {cid}")
Expand Down

0 comments on commit 93074c9

Please sign in to comment.