mirror of
https://github.com/ail-project/ail-framework.git
synced 2025-01-18 16:36:13 +00:00
chg: [message description] add chat name and username
This commit is contained in:
parent
d7b9aa2dd2
commit
55a35bf3f4
2 changed files with 41 additions and 1 deletions
|
@ -278,7 +278,7 @@ class Message(AbstractObject):
|
|||
if 'last_full_date' in options:
|
||||
meta['last_full_date'] = meta['full_date']
|
||||
|
||||
meta['source'] = self.get_source()
|
||||
# meta['source'] = self.get_source()
|
||||
# optional meta fields
|
||||
if 'content' in options:
|
||||
meta['content'] = self.get_content()
|
||||
|
@ -401,6 +401,35 @@ def create(obj_id, content, translation=None, tags=[]):
|
|||
# TODO Encode translation
|
||||
|
||||
|
||||
#####################################
|
||||
|
||||
# class Messages:
|
||||
# def __init__(self):
|
||||
# super().__init__('message', Message)
|
||||
#
|
||||
# def get_name(self):
|
||||
# return 'Messages'
|
||||
#
|
||||
# def get_icon(self):
|
||||
# return {'fas': 'fas', 'icon': 'comment-dots'}
|
||||
#
|
||||
# def get_link(self, flask_context=False):
|
||||
# # if flask_context:
|
||||
# # url = url_for('chats_explorer.chats_explorer_protocols')
|
||||
# # else:
|
||||
# # url = f'{baseurl}/chats/explorer/protocols'
|
||||
# return None
|
||||
#
|
||||
# # def get_by_date(self, date):
|
||||
# # pass
|
||||
#
|
||||
# def get_nb_by_date(self, date):
|
||||
# nb = 0
|
||||
# for subtype in self.get_subtypes():
|
||||
# nb += self.get_nb_by_date_subtype(subtype, date)
|
||||
# return nb
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = 'test'
|
||||
print(r)
|
||||
|
|
|
@ -162,10 +162,21 @@ def get_description():
|
|||
options = {'icon', 'tags', 'tags_safe'}
|
||||
if obj_type == 'message':
|
||||
options.add('content')
|
||||
options.add('chat')
|
||||
res = ail_objects.get_object_meta(obj_type, subtype, obj_id, options=options,
|
||||
flask_context=True)
|
||||
if 'tags' in res:
|
||||
res['tags'] = list(res['tags'])
|
||||
|
||||
if obj_type == 'message':
|
||||
chat_id = res['chat']
|
||||
subtype = object_id[9:].split('/', 1)[0]
|
||||
meta_chats = ail_objects.get_object_meta('chat', subtype, chat_id, options={'username', 'str_username'})
|
||||
if meta_chats["username"]:
|
||||
res['chat'] = f'{meta_chats["username"]} - {meta_chats["name"]}'
|
||||
else:
|
||||
res['chat'] = f'{meta_chats["name"]}'
|
||||
|
||||
return jsonify(res)
|
||||
|
||||
@correlation.route('/correlation/graph_node_json')
|
||||
|
|
Loading…
Add table
Reference in a new issue