fix: correlations

This commit is contained in:
Terrtia 2023-08-23 16:13:20 +02:00
parent 3c1813ba02
commit 843b2d3134
No known key found for this signature in database
GPG key ID: 1E1B1F50D84613D0
4 changed files with 16 additions and 9 deletions

View file

@ -79,7 +79,7 @@ class TelegramFeeder(DefaultFeeder):
if meta.get('chat'):
chat = Chat(meta['chat']['id'], 'telegram')
if meta['chat'].get('username'): # TODO USE ID AND SAVE USERNAME
if meta['chat'].get('username'): # SAVE USERNAME
chat_username = meta['chat']['username']
# Chat---Message
@ -99,7 +99,7 @@ class TelegramFeeder(DefaultFeeder):
chat = None
# message sender
if meta.get('sender'): # TODO handle message channel forward
if meta.get('sender'): # TODO handle message channel forward - check if is user
user_id = meta['sender']['id']
user_account = UsersAccount.UserAccount(user_id, 'telegram')
# UserAccount---Message
@ -117,10 +117,13 @@ class TelegramFeeder(DefaultFeeder):
if meta['sender'].get('username'):
username = Username(meta['sender']['username'], 'telegram')
user_account.add_correlation(username.type, username.get_subtype(r_str=True), username.id)
# TODO Update user_account<--->username timeline
# Username---Message
username.add(date, self.item_id) # TODO ####################################################################
if chat:
# Chat---Username
chat.add_correlation(username.type, username.get_subtype(r_str=True), username.id)
# if meta.get('fwd_from'):

View file

@ -117,9 +117,15 @@ class Chat(AbstractSubtypeObject): # TODO # ID == username ?????
def get_name(self): # get username ????
pass
# return username correlation
def get_users(self): # get participants ??? -> passive users ???
pass
# users that send at least a message else participants/spectator
# correlation created by messages
def get_users(self):
users = set()
accounts = self.get_correlation('user-account').get('user-account', [])
for account in accounts:
users.add(account[1:])
return users
# def get_last_message_id(self):
#

View file

@ -91,7 +91,7 @@ class Message(AbstractObject):
# message_id = message_id[:-3]
return message_id
def get_chat_id(self): # TODO optimize
def get_chat_id(self): # TODO optimize -> use me to tag Chat
chat_id = self.get_basename().rsplit('_', 1)[0]
# if chat_id.endswith('.gz'):
# chat_id = chat_id[:-3]

View file

@ -87,9 +87,7 @@ class UserAccount(AbstractSubtypeObject):
def get_usernames(self):
usernames = []
correl = self.get_correlation('username')
for partial_id in correl.get('username', []):
usernames.append(f'username:{partial_id}')
# TODO TIMELINE
return usernames
def get_meta(self, options=set()):