diff --git a/bin/importer/feeders/abstract_chats_feeder.py b/bin/importer/feeders/abstract_chats_feeder.py index 04bdd1e4..11d2fe89 100755 --- a/bin/importer/feeders/abstract_chats_feeder.py +++ b/bin/importer/feeders/abstract_chats_feeder.py @@ -193,7 +193,7 @@ class AbstractChatFeeder(DefaultFeeder, ABC): subchannel.add_message(obj.get_global_id(), self.get_message_id(), timestamp, reply_id=reply_id) return subchannel - def process_sender(self, obj, date, timestamp): + def process_sender(self, new_objs, obj, date, timestamp): meta = self.json_data['meta']['sender'] user_account = UsersAccount.UserAccount(meta['id'], self.get_chat_instance_uuid()) @@ -217,6 +217,12 @@ class AbstractChatFeeder(DefaultFeeder, ABC): if meta.get('phone'): user_account.set_phone(meta['phone']) + if meta.get('icon'): + img = Images.create(meta['icon'], b64=True) + img.add(date, user_account) + user_account.set_icon(img.get_global_id()) + new_objs.add(img) + return user_account # Create abstract class: -> new API endpoint ??? => force field, check if already imported ? @@ -271,7 +277,7 @@ class AbstractChatFeeder(DefaultFeeder, ABC): chat = self.process_chat(new_objs, obj, date, timestamp, reply_id=reply_id) # SENDER # TODO HANDLE NULL SENDER - user_account = self.process_sender(obj, date, timestamp) + user_account = self.process_sender(new_objs, obj, date, timestamp) # UserAccount---Chat user_account.add_correlation(chat.type, chat.get_subtype(r_str=True), chat.id) diff --git a/bin/lib/objects/UsersAccount.py b/bin/lib/objects/UsersAccount.py index 36df238b..3acc83bc 100755 --- a/bin/lib/objects/UsersAccount.py +++ b/bin/lib/objects/UsersAccount.py @@ -83,6 +83,14 @@ class UserAccount(AbstractSubtypeObject): def set_phone(self, phone): return self._set_field('phone', phone) + def get_icon(self): + icon = self._get_field('icon') + if icon: + return icon.rsplit(':', 1)[1] + + def set_icon(self, icon): + self._set_field('icon', icon) + def _get_timeline_username(self): return Timeline(self.get_global_id(), 'username') @@ -107,6 +115,8 @@ class UserAccount(AbstractSubtypeObject): meta['username'] = Usernames.Username(username_account_id, username_account_subtype).get_meta() if 'usernames' in options: meta['usernames'] = self.get_usernames() + if 'icon' in options: + meta['icon'] = self.get_icon() return meta def get_misp_object(self): diff --git a/var/www/templates/chats_explorer/block_message.html b/var/www/templates/chats_explorer/block_message.html index 3a9db11e..53f63f61 100644 --- a/var/www/templates/chats_explorer/block_message.html +++ b/var/www/templates/chats_explorer/block_message.html @@ -26,7 +26,8 @@
- {{ message['user-account']['id'] }} + {{ message['user-account']['id'] }}
{{ message['hour'] }}