@@ -197,10 +197,11 @@ def _process_chat(self, meta_chat, date, new_objs=None): #TODO NONE DATE???
197197
198198 if meta_chat .get ('icon' ):
199199 img = Images .create (meta_chat ['icon' ], b64 = True )
200- img .add (date , chat )
201- chat .set_icon (img .get_global_id ())
202- if new_objs :
203- new_objs .add (img )
200+ if img :
201+ img .add (date , chat )
202+ chat .set_icon (img .get_global_id ())
203+ if new_objs :
204+ new_objs .add (img )
204205
205206 if meta_chat .get ('username' ):
206207 username = Username (meta_chat ['username' ], self .get_chat_protocol ())
@@ -231,9 +232,10 @@ def process_chat(self, new_objs, obj, date, timestamp, feeder_timestamp, reply_i
231232
232233 if meta .get ('icon' ):
233234 img = Images .create (meta ['icon' ], b64 = True )
234- img .add (date , chat )
235- chat .set_icon (img .get_global_id ())
236- new_objs .add (img )
235+ if img :
236+ img .add (date , chat )
237+ chat .set_icon (img .get_global_id ())
238+ new_objs .add (img )
237239
238240 if meta .get ('username' ):
239241 username = Username (meta ['username' ], self .get_chat_protocol ())
@@ -370,9 +372,10 @@ def process_sender(self, new_objs, obj, date, timestamp):
370372
371373 if meta .get ('icon' ):
372374 img = Images .create (meta ['icon' ], b64 = True )
373- img .add (date , user_account )
374- user_account .set_icon (img .get_global_id ())
375- new_objs .add (img )
375+ if img :
376+ img .add (date , user_account )
377+ user_account .set_icon (img .get_global_id ())
378+ new_objs .add (img )
376379
377380 if meta .get ('info' ):
378381 user_account .set_info (meta ['info' ])
@@ -438,14 +441,15 @@ def process_meta(self): # TODO CHECK MANDATORY FIELDS
438441
439442 if self .obj .type == 'image' :
440443 obj = Images .create (self .get_message_content ())
441- obj .add (date , message )
442- obj .set_parent (obj_global_id = message .get_global_id ())
444+ if obj :
445+ obj .add (date , message )
446+ obj .set_parent (obj_global_id = message .get_global_id ())
443447
444- # FILENAME
445- media_name = self .get_media_name ()
446- if media_name :
447- f = FilesNames .FilesNames ().create (media_name , date , message , file_obj = obj )
448- objs .add (f )
448+ # FILENAME
449+ media_name = self .get_media_name ()
450+ if media_name :
451+ f = FilesNames .FilesNames ().create (media_name , date , message , file_obj = obj )
452+ objs .add (f )
449453
450454 elif self .obj .type == 'pdf' :
451455 # content
0 commit comments