From 61bccecdab60adb7e20c574bd90ac3c10efd4f5a Mon Sep 17 00:00:00 2001 From: terrtia Date: Fri, 26 Jan 2024 16:06:42 +0100 Subject: [PATCH] chg: [chats] show NB messages by chat --- bin/lib/chats_viewer.py | 2 +- bin/lib/objects/Chats.py | 2 ++ var/www/blueprints/chats_explorer.py | 2 +- var/www/templates/chats_explorer/chat_instance.html | 4 +++- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/bin/lib/chats_viewer.py b/bin/lib/chats_viewer.py index 3c46db5f..69b913f4 100755 --- a/bin/lib/chats_viewer.py +++ b/bin/lib/chats_viewer.py @@ -178,7 +178,7 @@ class ChatServiceInstance: if 'chats' in options: meta['chats'] = [] for chat_id in self.get_chats(): - meta['chats'].append(Chats.Chat(chat_id, self.uuid).get_meta({'created_at', 'icon', 'nb_subchannels'})) + meta['chats'].append(Chats.Chat(chat_id, self.uuid).get_meta({'created_at', 'icon', 'nb_subchannels', 'nb_messages'})) return meta def get_nb_chats(self): diff --git a/bin/lib/objects/Chats.py b/bin/lib/objects/Chats.py index e0dffd9d..746f0dea 100755 --- a/bin/lib/objects/Chats.py +++ b/bin/lib/objects/Chats.py @@ -83,6 +83,8 @@ class Chat(AbstractChatObject): meta['participants'] = self.get_participants() if 'nb_participants' in options: meta['nb_participants'] = self.get_nb_participants() + if 'nb_messages' in options: + meta['nb_messages'] = self.get_nb_messages() if 'username' in options: meta['username'] = self.get_username() if 'subchannels' in options: diff --git a/var/www/blueprints/chats_explorer.py b/var/www/blueprints/chats_explorer.py index eb817da3..38d6c413 100644 --- a/var/www/blueprints/chats_explorer.py +++ b/var/www/blueprints/chats_explorer.py @@ -63,7 +63,7 @@ def chats_explorer_networks(): return render_template('chats_networks.html', protocol=protocol, networks=networks) -@chats_explorer.route("chats/explorer/instance", methods=['GET']) +@chats_explorer.route("chats/explorer/instances", methods=['GET']) @login_required @login_read_only def chats_explorer_instance(): diff --git a/var/www/templates/chats_explorer/chat_instance.html b/var/www/templates/chats_explorer/chat_instance.html index 557ade0a..0f5e25ed 100644 --- a/var/www/templates/chats_explorer/chat_instance.html +++ b/var/www/templates/chats_explorer/chat_instance.html @@ -70,7 +70,8 @@ Created at First Seen Last Seen - NB SubChannels + SubChannels + Messages @@ -94,6 +95,7 @@ {% endif %} {{ chat['nb_subchannels'] }} + {{ chat['nb_messages'] }} {% endfor %}