mirror of
https://github.com/ail-project/ail-framework.git
synced 2024-11-26 15:57:16 +00:00
chg: [chats] get user message ids by chat
This commit is contained in:
parent
70bb6757f8
commit
c05f4d7833
4 changed files with 21 additions and 6 deletions
|
@ -318,7 +318,7 @@ class AbstractChatFeeder(DefaultFeeder, ABC):
|
|||
message.create('')
|
||||
objs.add(message)
|
||||
|
||||
if message.exists():
|
||||
if message.exists(): # TODO Correlation user-account image/filename ????
|
||||
obj = Images.create(self.get_message_content())
|
||||
obj.add(date, message)
|
||||
obj.set_parent(obj_global_id=message.get_global_id())
|
||||
|
@ -336,6 +336,8 @@ class AbstractChatFeeder(DefaultFeeder, ABC):
|
|||
# TODO get created subchannel + thread
|
||||
# => create correlation user-account with object
|
||||
|
||||
print(obj.id)
|
||||
|
||||
# CHAT
|
||||
chat_objs = self.process_chat(new_objs, obj, date, timestamp, reply_id=reply_id)
|
||||
|
||||
|
|
|
@ -123,6 +123,9 @@ def is_obj_correlated(obj_type, subtype, obj_id, obj2_type, subtype2, obj2_id):
|
|||
except:
|
||||
return False
|
||||
|
||||
def get_obj_inter_correlation(obj_type1, subtype1, obj_id1, obj_type2, subtype2, obj_id2, correl_type):
|
||||
return r_metadata.sinter(f'correlation:obj:{obj_type1}:{subtype1}:{correl_type}:{obj_id1}', f'correlation:obj:{obj_type2}:{subtype2}:{correl_type}:{obj_id2}')
|
||||
|
||||
def add_obj_correlation(obj1_type, subtype1, obj1_id, obj2_type, subtype2, obj2_id):
|
||||
if subtype1 is None:
|
||||
subtype1 = ''
|
||||
|
|
|
@ -119,6 +119,9 @@ class UserAccount(AbstractSubtypeObject):
|
|||
def update_username_timeline(self, username_global_id, timestamp):
|
||||
self._get_timeline_username().add_timestamp(timestamp, username_global_id)
|
||||
|
||||
def get_messages_by_chat_obj(self, chat_obj):
|
||||
return self.get_correlation_iter_obj(chat_obj, 'message')
|
||||
|
||||
def get_meta(self, options=set()): # TODO Username timeline
|
||||
meta = self._get_meta(options=options)
|
||||
meta['id'] = self.id
|
||||
|
@ -191,7 +194,8 @@ def get_all_by_subtype(subtype):
|
|||
return get_all_id('user-account', subtype)
|
||||
|
||||
|
||||
# if __name__ == '__main__':
|
||||
# name_to_search = 'co'
|
||||
# subtype = 'telegram'
|
||||
# print(search_usernames_by_name(name_to_search, subtype))
|
||||
if __name__ == '__main__':
|
||||
from lib.objects import Chats
|
||||
chat = Chats.Chat('', '00098785-7e70-5d12-a120-c5cdc1252b2b')
|
||||
account = UserAccount('', '00098785-7e70-5d12-a120-c5cdc1252b2b')
|
||||
print(account.get_messages_by_chat_obj(chat))
|
||||
|
|
|
@ -22,7 +22,7 @@ from lib import ail_logger
|
|||
from lib import Tag
|
||||
from lib.ConfigLoader import ConfigLoader
|
||||
from lib import Duplicate
|
||||
from lib.correlations_engine import get_nb_correlations, get_correlations, add_obj_correlation, delete_obj_correlation, delete_obj_correlations, exists_obj_correlation, is_obj_correlated, get_nb_correlation_by_correl_type
|
||||
from lib.correlations_engine import get_nb_correlations, get_correlations, add_obj_correlation, delete_obj_correlation, delete_obj_correlations, exists_obj_correlation, is_obj_correlated, get_nb_correlation_by_correl_type, get_obj_inter_correlation
|
||||
from lib.Investigations import is_object_investigated, get_obj_investigations, delete_obj_investigations
|
||||
from lib.Tracker import is_obj_tracked, get_obj_trackers, delete_obj_trackers
|
||||
|
||||
|
@ -270,6 +270,12 @@ class AbstractObject(ABC):
|
|||
return is_obj_correlated(self.type, self.subtype, self.id,
|
||||
object2.get_type(), object2.get_subtype(r_str=True), object2.get_id())
|
||||
|
||||
def get_correlation_iter(self, obj_type2, subtype2, obj_id2, correl_type):
|
||||
return get_obj_inter_correlation(self.type, self.get_subtype(r_str=True), self.id, obj_type2, subtype2, obj_id2, correl_type)
|
||||
|
||||
def get_correlation_iter_obj(self, object2, correl_type):
|
||||
return self.get_correlation_iter(object2.get_type(), object2.get_subtype(r_str=True), object2.get_id(), correl_type)
|
||||
|
||||
def delete_correlation(self, type2, subtype2, id2):
|
||||
"""
|
||||
Get object correlations
|
||||
|
|
Loading…
Reference in a new issue