From fb1ad5800c9c35e6c2d0a429a0f0f796f8e44811 Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Mon, 5 Mar 2018 22:07:16 +0100 Subject: [PATCH] Minor fix for `searchFor`. See comments on #266 --- fbchat/__init__.py | 2 +- fbchat/graphql.py | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/fbchat/__init__.py b/fbchat/__init__.py index cbff6337..dc14167d 100644 --- a/fbchat/__init__.py +++ b/fbchat/__init__.py @@ -17,7 +17,7 @@ __copyright__ = 'Copyright 2015 - {} by Taehoon Kim'.format(datetime.now().year) -__version__ = '1.3.3' +__version__ = '1.3.4' __license__ = 'BSD' __author__ = 'Taehoon Kim; Moreels Pieter-Jan; Mads Marquart' __email__ = 'carpedm20@gmail.com' diff --git a/fbchat/graphql.py b/fbchat/graphql.py index a0b95000..323a0467 100644 --- a/fbchat/graphql.py +++ b/fbchat/graphql.py @@ -181,7 +181,9 @@ def graphql_to_thread(thread): c_info = get_customization_info(thread) participants = [node['messaging_actor'] for node in thread['all_participants']['nodes']] user = next(p for p in participants if p['id'] == thread['thread_key']['other_user_id']) - last_message_timestamp = thread['last_message']['nodes'][0]['timestamp_precise'] + last_message_timestamp = None + if 'last_message' in thread: + last_message_timestamp = thread['last_message']['nodes'][0]['timestamp_precise'] return User( user['id'], @@ -207,7 +209,9 @@ def graphql_to_group(group): if group.get('image') is None: group['image'] = {} c_info = get_customization_info(group) - last_message_timestamp = group['last_message']['nodes'][0]['timestamp_precise'] + last_message_timestamp = None + if 'last_message' in group: + last_message_timestamp = group['last_message']['nodes'][0]['timestamp_precise'] return Group( group['thread_key']['thread_fbid'], participants=set([node['messaging_actor']['id'] for node in group['all_participants']['nodes']]),