From f480d68b5773473e6daba7f66075ee30e8d737a8 Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Thu, 25 Apr 2019 23:03:05 +0200 Subject: [PATCH] Fix subattachment `target` parsing, fixes #412 --- fbchat/_file.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fbchat/_file.py b/fbchat/_file.py index 00c8a32..45cd282 100644 --- a/fbchat/_file.py +++ b/fbchat/_file.py @@ -268,8 +268,10 @@ def graphql_to_attachment(data): def graphql_to_subattachment(data): - _type = data["target"]["__typename"] - if _type == "Video": + target = data.get("target") + type_ = target.get("__typename") if target else None + + if type_ == "Video": return VideoAttachment._from_subattachment(data) return None