diff --git a/chat_server/sio/handlers/translation.py b/chat_server/sio/handlers/translation.py index e633171e..573988e4 100644 --- a/chat_server/sio/handlers/translation.py +++ b/chat_server/sio/handlers/translation.py @@ -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( diff --git a/utils/database_utils/mongo_utils/queries/mongo_queries.py b/utils/database_utils/mongo_utils/queries/mongo_queries.py index 5528f04a..2bb27c43 100644 --- a/utils/database_utils/mongo_utils/queries/mongo_queries.py +++ b/utils/database_utils/mongo_utils/queries/mongo_queries.py @@ -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 """ @@ -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}")