mirror of
https://github.com/ail-project/ail-framework.git
synced 2024-11-26 15:57:16 +00:00
chg: [chats explorer] show chats/subchannels creation date
This commit is contained in:
parent
3fb1d0ad74
commit
4cc9608a3f
7 changed files with 25 additions and 11 deletions
|
@ -173,7 +173,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({'nb_subchannels'}))
|
||||
meta['chats'].append(Chats.Chat(chat_id, self.uuid).get_meta({'created_at', 'nb_subchannels'}))
|
||||
return meta
|
||||
|
||||
def get_nb_chats(self):
|
||||
|
@ -297,7 +297,7 @@ def api_get_chat(chat_id, chat_instance_uuid):
|
|||
chat = Chats.Chat(chat_id, chat_instance_uuid)
|
||||
if not chat.exists():
|
||||
return {"status": "error", "reason": "Unknown chat"}, 404
|
||||
meta = chat.get_meta({'img', 'info', 'subchannels', 'username'})
|
||||
meta = chat.get_meta({'created_at', 'img', 'info', 'subchannels', 'username'})
|
||||
if meta['subchannels']:
|
||||
meta['subchannels'] = get_subchannels_meta_from_global_id(meta['subchannels'])
|
||||
else:
|
||||
|
@ -308,7 +308,7 @@ def api_get_subchannel(chat_id, chat_instance_uuid):
|
|||
subchannel = ChatSubChannels.ChatSubChannel(chat_id, chat_instance_uuid)
|
||||
if not subchannel.exists():
|
||||
return {"status": "error", "reason": "Unknown chat"}, 404
|
||||
meta = subchannel.get_meta({'chat', 'img', 'nb_messages'})
|
||||
meta = subchannel.get_meta({'chat', 'created_at', 'img', 'nb_messages'})
|
||||
if meta['chat']:
|
||||
meta['chat'] = get_chat_meta_from_global_id(meta['chat'])
|
||||
meta['messages'], meta['tags_messages'] = subchannel.get_messages()
|
||||
|
|
|
@ -86,6 +86,8 @@ class ChatSubChannel(AbstractChatObject):
|
|||
meta['img'] = self.get_img()
|
||||
if 'nb_messages':
|
||||
meta['nb_messages'] = self.get_nb_messages()
|
||||
if 'created_at':
|
||||
meta['created_at'] = self.get_created_at(date=True)
|
||||
return meta
|
||||
|
||||
def get_misp_object(self):
|
||||
|
|
|
@ -84,6 +84,8 @@ class Chat(AbstractChatObject):
|
|||
meta['subchannels'] = self.get_subchannels()
|
||||
if 'nb_subchannels':
|
||||
meta['nb_subchannels'] = self.get_nb_subchannels()
|
||||
if 'created_at':
|
||||
meta['created_at'] = self.get_created_at(date=True)
|
||||
return meta
|
||||
|
||||
def get_misp_object(self):
|
||||
|
|
|
@ -94,8 +94,12 @@ class AbstractChatObject(AbstractSubtypeObject, ABC):
|
|||
threads.append(obj_global_id)
|
||||
return threads
|
||||
|
||||
def get_created_at(self):
|
||||
return self._get_field('created_at')
|
||||
def get_created_at(self, date=False):
|
||||
created_at = self._get_field('created_at')
|
||||
if date and created_at:
|
||||
created_at = datetime.fromtimestamp(float(created_at))
|
||||
created_at = created_at.isoformat(' ')
|
||||
return created_at
|
||||
|
||||
def set_created_at(self, timestamp):
|
||||
self._set_field('created_at', timestamp)
|
||||
|
|
|
@ -63,7 +63,7 @@
|
|||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
{# <th>Chat Instance</th>#}
|
||||
<th>Created at</th>
|
||||
<th>First seen</th>
|
||||
<th>Last seen</th>
|
||||
<th>Username</th>
|
||||
|
@ -73,9 +73,9 @@
|
|||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
{# {{ subchannel["subtype"] }}#}
|
||||
{{ subchannel['name'] }}
|
||||
</td>
|
||||
<td>{{ subchannel["created_at"] }}</td>
|
||||
<td>
|
||||
{% if subchannel['first_seen'] %}
|
||||
{{ subchannel['first_seen'][0:4] }}-{{ subchannel['first_seen'][4:6] }}-{{ subchannel['first_seen'][6:8] }}
|
||||
|
|
|
@ -67,9 +67,10 @@
|
|||
<th>Icon</th>
|
||||
<th>Name</th>
|
||||
<th>ID</th>
|
||||
<th>Created at</th>
|
||||
<th>First Seen</th>
|
||||
<th>Last Seen</th>
|
||||
<th>NB Chats</th>
|
||||
<th>NB SubChannels</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody style="font-size: 15px;">
|
||||
|
@ -78,8 +79,9 @@
|
|||
<td>
|
||||
<img src="{{ url_for('static', filename='image/ail-icon.png') }}" class="rounded-circle mr-1" alt="{{ chat['id'] }}" width="40" height="40">
|
||||
</td>
|
||||
<td>{{ chat['name'] }}</td>
|
||||
<td><b>{{ chat['name'] }}</b></td>
|
||||
<td><a href="{{ url_for('chats_explorer.chats_explorer_chat') }}?uuid={{ chat_instance['uuid'] }}&id={{ chat['id'] }}">{{ chat['id'] }}</a></td>
|
||||
<td>{{ chat['created_at'] }}</td>
|
||||
<td>
|
||||
{% if chat['first_seen'] %}
|
||||
{{ chat['first_seen'][0:4] }}-{{ chat['first_seen'][4:6] }}-{{ chat['first_seen'][6:8] }}
|
||||
|
@ -109,7 +111,7 @@
|
|||
$('#tablechats').DataTable({
|
||||
"aLengthMenu": [[5, 10, 15, -1], [5, 10, 15, "All"]],
|
||||
"iDisplayLength": 10,
|
||||
"order": [[ 4, "desc" ]]
|
||||
"order": [[ 5, "desc" ]]
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -60,6 +60,7 @@
|
|||
<th>Icon</th>
|
||||
<th>Name</th>
|
||||
<th>ID</th>
|
||||
<th>Created at</th>
|
||||
<th>First Seen</th>
|
||||
<th>Last Seen</th>
|
||||
<th>NB Sub-Channels</th>
|
||||
|
@ -70,6 +71,7 @@
|
|||
<td></td>
|
||||
<td>{{ chat['name'] }}</td>
|
||||
<td>{{ chat['id'] }}</td>
|
||||
<td>{{ chat['created_at'] }}</td>
|
||||
<td>
|
||||
{% if chat['first_seen'] %}
|
||||
{{ chat['first_seen'][0:4] }}-{{ chat['first_seen'][4:6] }}-{{ chat['first_seen'][6:8] }}
|
||||
|
@ -107,6 +109,7 @@
|
|||
<th>Icon</th>
|
||||
<th>Name</th>
|
||||
<th>ID</th>
|
||||
<th>Created at</th>
|
||||
<th>First Seen</th>
|
||||
<th>Last Seen</th>
|
||||
<th>NB Messages</th>
|
||||
|
@ -120,6 +123,7 @@
|
|||
</td>
|
||||
<td><b>{{ meta['name'] }}</b></td>
|
||||
<td><a href="{{ url_for('chats_explorer.objects_subchannel_messages') }}?uuid={{ meta['subtype'] }}&id={{ meta['id'] }}">{{ meta['id'] }}</a></td>
|
||||
<td>{{ meta['created_at'] }}</td>
|
||||
<td>
|
||||
{% if meta['first_seen'] %}
|
||||
{{ meta['first_seen'][0:4] }}-{{ meta['first_seen'][4:6] }}-{{ meta['first_seen'][6:8] }}
|
||||
|
@ -220,7 +224,7 @@
|
|||
$('#tablesubchannels').DataTable({
|
||||
"aLengthMenu": [[5, 10, 15, -1], [5, 10, 15, "All"]],
|
||||
"iDisplayLength": 10,
|
||||
"order": [[ 4, "desc" ]]
|
||||
"order": [[ 5, "desc" ]]
|
||||
});
|
||||
{% endif %}
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue