From 5faca54d67201531f1c4f5781a29753e8ad7deb7 Mon Sep 17 00:00:00 2001 From: Joe Lau Date: Mon, 26 Jun 2017 14:16:57 -0700 Subject: [PATCH 1/3] Handle empty participant_customizations field --- fbchat/graphql.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fbchat/graphql.py b/fbchat/graphql.py index 74060e6..c8a9a9c 100644 --- a/fbchat/graphql.py +++ b/fbchat/graphql.py @@ -44,7 +44,7 @@ def get_customization_info(thread): rtn['nicknames'] = {} for k in info['participant_customizations']: rtn['nicknames'][k['participant_id']] = k.get('nickname') - else: + elif info['participant_customizations']: _id = thread.get('thread_key', {}).get('other_user_id') or thread.get('id') if info['participant_customizations'][0]['participant_id'] == _id: rtn['nickname'] = info['participant_customizations'][0] From 35bbcbffba26df58cbe46e718f0159547ed79a33 Mon Sep 17 00:00:00 2001 From: Joe Lau Date: Mon, 26 Jun 2017 17:54:25 -0700 Subject: [PATCH 2/3] Add __init__.py --- __init__.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 __init__.py diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..e69de29 From 5f993c2bf8d8bafa7e1c73ac224885e5fec89030 Mon Sep 17 00:00:00 2001 From: Joe Lau Date: Tue, 27 Jun 2017 16:16:51 -0700 Subject: [PATCH 3/3] Use .get() instead --- fbchat/graphql.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fbchat/graphql.py b/fbchat/graphql.py index c8a9a9c..61b3e17 100644 --- a/fbchat/graphql.py +++ b/fbchat/graphql.py @@ -44,7 +44,7 @@ def get_customization_info(thread): rtn['nicknames'] = {} for k in info['participant_customizations']: rtn['nicknames'][k['participant_id']] = k.get('nickname') - elif info['participant_customizations']: + elif info.get('participant_customizations'): _id = thread.get('thread_key', {}).get('other_user_id') or thread.get('id') if info['participant_customizations'][0]['participant_id'] == _id: rtn['nickname'] = info['participant_customizations'][0]