Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #388 issue #389

Merged
merged 2 commits into from
Feb 3, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 24 additions & 30 deletions fbchat/graphql.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,11 @@ def graphql_to_extensible_attachment(a):
latitude=float(latitude),
longitude=float(longitude),
)
if story["media"]:
rtn.image_url = story["media"]["image"]["uri"]
rtn.image_width = story["media"]["image"]["width"]
rtn.image_height = story["media"]["image"]["height"]
if story.get("media"):
if story["media"].get("image"):
rtn.image_url = story["media"]["image"]["uri"]
rtn.image_width = story["media"]["image"]["width"]
rtn.image_height = story["media"]["image"]["height"]
rtn.url = story["url"]
return rtn
elif _type == "MessageLiveLocation":
Expand All @@ -166,19 +167,18 @@ def graphql_to_extensible_attachment(a):
if story["target"].get("coordinate")
else None,
name=story["title_with_entities"]["text"],
expiration_time=story["target"]["expiration_time"]
if story["target"].get("expiration_time")
else None,
is_expired=story["target"]["is_expired"],
expiration_time=story["target"].get("expiration_time"),
is_expired=story["target"].get("is_expired"),
)
if story["media"]:
rtn.image_url = story["media"]["image"]["uri"]
rtn.image_width = story["media"]["image"]["width"]
rtn.image_height = story["media"]["image"]["height"]
if story.get("media"):
if story["media"].get("image"):
rtn.image_url = story["media"]["image"]["uri"]
rtn.image_width = story["media"]["image"]["width"]
rtn.image_height = story["media"]["image"]["height"]
rtn.url = story["url"]
return rtn
elif _type in ["ExternalUrl", "Story"]:
return ShareAttachment(
rtn = ShareAttachment(
kapi2289 marked this conversation as resolved.
Show resolved Hide resolved
uid=a.get("legacy_attachment_id"),
author=story["target"]["actors"][0]["id"]
if story["target"].get("actors")
Expand All @@ -191,28 +191,22 @@ def graphql_to_extensible_attachment(a):
description=story["description"].get("text")
if story.get("description")
else None,
source=story["source"]["text"],
image_url=story["media"]["image"]["uri"]
if story.get("media")
else None,
original_image_url=(
get_url_parameter(story["media"]["image"]["uri"], "url")
if "/safe_image.php" in story["media"]["image"]["uri"]
else story["media"]["image"]["uri"]
)
if story.get("media")
else None,
image_width=story["media"]["image"]["width"]
if story.get("media")
else None,
image_height=story["media"]["image"]["height"]
if story.get("media")
else None,
source=story["source"].get("text"),
attachments=[
graphql_to_subattachment(attachment)
for attachment in story.get("subattachments")
],
)
if story.get("media"):
if story["media"].get("image"):
kapi2289 marked this conversation as resolved.
Show resolved Hide resolved
rtn.image_url = story["media"]["image"]["uri"]
rtn.original_image_url = (
get_url_parameter(story["media"]["image"]["uri"], "url")
if "/safe_image.php" in story["media"]["image"]["uri"]
else story["media"]["image"]["uri"]
)
rtn.image_width = story["media"]["image"]["width"]
rtn.image_height = story["media"]["image"]["height"]
else:
return UnsentMessage(uid=a.get("legacy_attachment_id"))

Expand Down