Skip to content

Commit 55a35bf

Browse files
committed
chg: [message description] add chat name and username
1 parent d7b9aa2 commit 55a35bf

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

bin/lib/objects/Messages.py

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ def get_meta(self, options=None, timestamp=None, translation_target=''):
278278
if 'last_full_date' in options:
279279
meta['last_full_date'] = meta['full_date']
280280

281-
meta['source'] = self.get_source()
281+
# meta['source'] = self.get_source()
282282
# optional meta fields
283283
if 'content' in options:
284284
meta['content'] = self.get_content()
@@ -401,6 +401,35 @@ def create(obj_id, content, translation=None, tags=[]):
401401
# TODO Encode translation
402402

403403

404+
#####################################
405+
406+
# class Messages:
407+
# def __init__(self):
408+
# super().__init__('message', Message)
409+
#
410+
# def get_name(self):
411+
# return 'Messages'
412+
#
413+
# def get_icon(self):
414+
# return {'fas': 'fas', 'icon': 'comment-dots'}
415+
#
416+
# def get_link(self, flask_context=False):
417+
# # if flask_context:
418+
# # url = url_for('chats_explorer.chats_explorer_protocols')
419+
# # else:
420+
# # url = f'{baseurl}/chats/explorer/protocols'
421+
# return None
422+
#
423+
# # def get_by_date(self, date):
424+
# # pass
425+
#
426+
# def get_nb_by_date(self, date):
427+
# nb = 0
428+
# for subtype in self.get_subtypes():
429+
# nb += self.get_nb_by_date_subtype(subtype, date)
430+
# return nb
431+
432+
404433
if __name__ == '__main__':
405434
r = 'test'
406435
print(r)

var/www/blueprints/correlation.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,21 @@ def get_description():
162162
options = {'icon', 'tags', 'tags_safe'}
163163
if obj_type == 'message':
164164
options.add('content')
165+
options.add('chat')
165166
res = ail_objects.get_object_meta(obj_type, subtype, obj_id, options=options,
166167
flask_context=True)
167168
if 'tags' in res:
168169
res['tags'] = list(res['tags'])
170+
171+
if obj_type == 'message':
172+
chat_id = res['chat']
173+
subtype = object_id[9:].split('/', 1)[0]
174+
meta_chats = ail_objects.get_object_meta('chat', subtype, chat_id, options={'username', 'str_username'})
175+
if meta_chats["username"]:
176+
res['chat'] = f'{meta_chats["username"]} - {meta_chats["name"]}'
177+
else:
178+
res['chat'] = f'{meta_chats["name"]}'
179+
169180
return jsonify(res)
170181

171182
@correlation.route('/correlation/graph_node_json')

0 commit comments

Comments
 (0)