From 18dbd0002fdaeed95781381e4c707ba6205ab368 Mon Sep 17 00:00:00 2001 From: terrtia Date: Wed, 29 Jan 2025 14:20:21 +0100 Subject: [PATCH] chg: [chat explorer] show files tags --- bin/lib/objects/Messages.py | 4 ++-- bin/lib/objects/abstract_object.py | 6 ++++++ .../chats_explorer/block_message.html | 20 ++++++++++++++++--- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/bin/lib/objects/Messages.py b/bin/lib/objects/Messages.py index f1c7ed43..fe1e1f38 100755 --- a/bin/lib/objects/Messages.py +++ b/bin/lib/objects/Messages.py @@ -193,14 +193,14 @@ class Message(AbstractObject): for it in self.get_correlation_iter('file-name', '', file_name, 'item'): if file_name not in files: files[file_name] = [] - files[file_name].append(it[1:]) + files[file_name].append({'obj': it[1:], 'tags': self.get_obj_tags('item', '', it[1:])}) s_files.add(it[1:]) nb_files += 1 if nb_files < self.get_nb_files(): files['undefined'] = [] for f in self.get_correlation('item').get('item'): if f[1:] not in s_files: - files['undefined'].append(f[1:]) + files['undefined'].append({'obj': f[1:], 'tags': self.get_obj_tags('item', '', f[1:])}) return files def get_reactions(self): diff --git a/bin/lib/objects/abstract_object.py b/bin/lib/objects/abstract_object.py index 4b230f11..a157a4fe 100755 --- a/bin/lib/objects/abstract_object.py +++ b/bin/lib/objects/abstract_object.py @@ -109,6 +109,12 @@ class AbstractObject(ABC): tags = list(tags) return tags + def get_obj_tags(self, obj_type, subtype, obj_id, r_list=False): + tags = Tag.get_object_tags(obj_type, obj_id, subtype) + if r_list: + tags = list(tags) + return tags + def add_tag(self, tag): Tag.add_object_tag(tag, self.type, self.id, subtype=self.get_subtype(r_str=True)) diff --git a/var/www/templates/chats_explorer/block_message.html b/var/www/templates/chats_explorer/block_message.html index 1184937f..9dd14af2 100644 --- a/var/www/templates/chats_explorer/block_message.html +++ b/var/www/templates/chats_explorer/block_message.html @@ -134,15 +134,29 @@ {% if message['files'][file_name] | length > 1 %}
{{ file_name }} - {% for item in message['files'][file_name] %} + {% for obj in message['files'][file_name] %}
- {{ loop.index }} + {{ loop.index }} + {% if obj['tags'] %} +
+ {% for tag in obj['tags'] %} + {{ tag }} + {% endfor %} +
+ {% endif %} {% endfor %}
{% else %} - +
{{ file_name }} + {% if message['files'][file_name][0]['tags'] %} +
+ {% for tag in message['files'][file_name][0]['tags'] %} + {{ tag }} + {% endfor %} +
+ {% endif %}
{% endif %}