fix: [chat view] fix created_at + filter

This commit is contained in:
terrtia 2024-01-29 10:52:18 +01:00
parent 6a24c58c8b
commit 6363a4f1cf
No known key found for this signature in database
GPG key ID: 1E1B1F50D84613D0
4 changed files with 9 additions and 13 deletions

View file

@ -280,7 +280,6 @@ def create_chat_service_instance(protocol, network=None, address=None):
####################################################################################### #######################################################################################
def get_obj_chat(chat_type, chat_subtype, chat_id): def get_obj_chat(chat_type, chat_subtype, chat_id):
print(chat_type, chat_subtype, chat_id)
if chat_type == 'chat': if chat_type == 'chat':
return Chats.Chat(chat_id, chat_subtype) return Chats.Chat(chat_id, chat_subtype)
elif chat_type == 'chat-subchannel': elif chat_type == 'chat-subchannel':
@ -305,7 +304,7 @@ def get_subchannels_meta_from_global_id(subchannels):
for sub in subchannels: for sub in subchannels:
_, instance_uuid, sub_id = sub.split(':', 2) _, instance_uuid, sub_id = sub.split(':', 2)
subchannel = ChatSubChannels.ChatSubChannel(sub_id, instance_uuid) subchannel = ChatSubChannels.ChatSubChannel(sub_id, instance_uuid)
meta.append(subchannel.get_meta({'nb_messages'})) meta.append(subchannel.get_meta({'nb_messages', 'created_at', 'icon'}))
return meta return meta
def get_chat_meta_from_global_id(chat_global_id): def get_chat_meta_from_global_id(chat_global_id):
@ -399,9 +398,6 @@ def api_get_message(message_id, translation_target=None):
if not message.exists(): if not message.exists():
return {"status": "error", "reason": "Unknown uuid"}, 404 return {"status": "error", "reason": "Unknown uuid"}, 404
meta = message.get_meta({'chat', 'content', 'files-names', 'icon', 'images', 'link', 'parent', 'parent_meta', 'reactions', 'thread', 'translation', 'user-account'}, translation_target=translation_target) meta = message.get_meta({'chat', 'content', 'files-names', 'icon', 'images', 'link', 'parent', 'parent_meta', 'reactions', 'thread', 'translation', 'user-account'}, translation_target=translation_target)
# if meta['chat']:
# print(meta['chat'])
# # meta['chat'] =
return meta, 200 return meta, 200
def api_get_user_account(user_id, instance_uuid): def api_get_user_account(user_id, instance_uuid):

View file

@ -82,8 +82,9 @@ class ChatSubChannel(AbstractChatObject):
meta['name'] = self.get_name() meta['name'] = self.get_name()
if 'chat' in options: if 'chat' in options:
meta['chat'] = self.get_chat() meta['chat'] = self.get_chat()
if 'img' in options: if 'icon' in options:
meta['img'] = self.get_img() meta['icon'] = self.get_icon()
meta['img'] = meta['icon']
if 'nb_messages' in options: if 'nb_messages' in options:
meta['nb_messages'] = self.get_nb_messages() meta['nb_messages'] = self.get_nb_messages()
if 'created_at' in options: if 'created_at' in options:

View file

@ -95,7 +95,6 @@ class Chat(AbstractChatObject):
meta['created_at'] = self.get_created_at(date=True) meta['created_at'] = self.get_created_at(date=True)
if 'threads' in options: if 'threads' in options:
meta['threads'] = self.get_threads() meta['threads'] = self.get_threads()
print(meta['threads'])
if 'tags_safe' in options: if 'tags_safe' in options:
meta['tags_safe'] = self.is_tags_safe(meta['tags']) meta['tags_safe'] = self.is_tags_safe(meta['tags'])
return meta return meta

View file

@ -39,9 +39,9 @@
</div> </div>
</div> </div>
<link href="{{ url_for('static', filename='css/daterangepicker.min.css') }}" rel="stylesheet"> {#<link href="{{ url_for('static', filename='css/daterangepicker.min.css') }}" rel="stylesheet">#}
<script src="{{ url_for('static', filename='js/moment.min.js') }}"></script> {#<script src="{{ url_for('static', filename='js/moment.min.js') }}"></script>#}
<script src="{{ url_for('static', filename='js/jquery.daterangepicker.min.js') }}"></script> {#<script src="{{ url_for('static', filename='js/jquery.daterangepicker.min.js') }}"></script>#}
<script> <script>
function filter_by_time() { function filter_by_time() {
@ -55,7 +55,7 @@
} }
$('#date-range-from').dateRangePicker({ /*$('#date-range-from').dateRangePicker({
separator : ' to ', separator : ' to ',
getValue: function(){ getValue: function(){
if ($('#date-range-from-input').val() && $('#date-range-to-input').val() ) if ($('#date-range-from-input').val() && $('#date-range-to-input').val() )
@ -80,6 +80,6 @@
$('#date-range-from-input').val(s1); $('#date-range-from-input').val(s1);
$('#date-range-to-input').val(s2); $('#date-range-to-input').val(s2);
} }
}); });*/
</script> </script>