diff --git a/bin/lib/Language.py b/bin/lib/Language.py index d7b8c1c8..03293bed 100755 --- a/bin/lib/Language.py +++ b/bin/lib/Language.py @@ -405,7 +405,7 @@ def _get_obj_translation(obj_global_id, language, source=None, content=None, fie translation = r_get_obj_translation(obj_global_id, language, field=field) if not translation: source, translation = LanguageTranslator().translate(content, source=source, target=language) - if source and translation: + if source: obj_type, subtype, obj_id = obj_global_id.split(':', 2) add_obj_language(source, obj_type, subtype, obj_id, objs_containers=objs_containers) if translation: diff --git a/bin/lib/chats_viewer.py b/bin/lib/chats_viewer.py index 6d660c9e..1f4a0084 100755 --- a/bin/lib/chats_viewer.py +++ b/bin/lib/chats_viewer.py @@ -468,6 +468,7 @@ def api_get_thread(thread_id, thread_instance_uuid, translation_target=None, nb= thread = ChatThreads.ChatThread(thread_id, thread_instance_uuid) if not thread.exists(): return {"status": "error", "reason": "Unknown thread"}, 404 + # print(thread.get_obj_language_stats()) meta = thread.get_meta({'chat', 'nb_messages', 'nb_participants'}) # if meta['chat']: # meta['chat'] = get_chat_meta_from_global_id(meta['chat']) diff --git a/bin/lib/objects/Messages.py b/bin/lib/objects/Messages.py index fbcad8f7..3340de2a 100755 --- a/bin/lib/objects/Messages.py +++ b/bin/lib/objects/Messages.py @@ -115,6 +115,12 @@ class Message(AbstractObject): if subchannel.get('chat-subchannel'): return f'chat-subchannel:{subchannel["chat-subchannel"].pop()}' + def get_current_thread(self): + subchannel = self.get_correlation('chat-thread') + if subchannel.get('chat-thread'): + return f'chat-thread:{subchannel["chat-thread"].pop()}' + + # children thread def get_thread(self): for child in self.get_childrens(): obj_type, obj_subtype, obj_id = child.split(':', 2) @@ -319,9 +325,9 @@ class Message(AbstractObject): subchannel = self.get_subchannel() if subchannel: objs_containers.add(subchannel) - # thread = self.get_thread() # TODO Get current thread - # if thread: - # objs_containers.add(thread) + thread = self.get_current_thread() + if thread: + objs_containers.add(thread) return objs_containers #- Language -#