Fix #388 issue
This commit is contained in:
@@ -150,10 +150,11 @@ def graphql_to_extensible_attachment(a):
|
|||||||
latitude=float(latitude),
|
latitude=float(latitude),
|
||||||
longitude=float(longitude),
|
longitude=float(longitude),
|
||||||
)
|
)
|
||||||
if story["media"]:
|
if story.get("media"):
|
||||||
rtn.image_url = story["media"]["image"]["uri"]
|
if story["media"].get("image"):
|
||||||
rtn.image_width = story["media"]["image"]["width"]
|
rtn.image_url = story["media"]["image"]["uri"]
|
||||||
rtn.image_height = story["media"]["image"]["height"]
|
rtn.image_width = story["media"]["image"]["width"]
|
||||||
|
rtn.image_height = story["media"]["image"]["height"]
|
||||||
rtn.url = story["url"]
|
rtn.url = story["url"]
|
||||||
return rtn
|
return rtn
|
||||||
elif _type == "MessageLiveLocation":
|
elif _type == "MessageLiveLocation":
|
||||||
@@ -166,19 +167,18 @@ def graphql_to_extensible_attachment(a):
|
|||||||
if story["target"].get("coordinate")
|
if story["target"].get("coordinate")
|
||||||
else None,
|
else None,
|
||||||
name=story["title_with_entities"]["text"],
|
name=story["title_with_entities"]["text"],
|
||||||
expiration_time=story["target"]["expiration_time"]
|
expiration_time=story["target"].get("expiration_time"),
|
||||||
if story["target"].get("expiration_time")
|
is_expired=story["target"].get("is_expired"),
|
||||||
else None,
|
|
||||||
is_expired=story["target"]["is_expired"],
|
|
||||||
)
|
)
|
||||||
if story["media"]:
|
if story.get("media"):
|
||||||
rtn.image_url = story["media"]["image"]["uri"]
|
if story["media"].get("image"):
|
||||||
rtn.image_width = story["media"]["image"]["width"]
|
rtn.image_url = story["media"]["image"]["uri"]
|
||||||
rtn.image_height = story["media"]["image"]["height"]
|
rtn.image_width = story["media"]["image"]["width"]
|
||||||
|
rtn.image_height = story["media"]["image"]["height"]
|
||||||
rtn.url = story["url"]
|
rtn.url = story["url"]
|
||||||
return rtn
|
return rtn
|
||||||
elif _type in ["ExternalUrl", "Story"]:
|
elif _type in ["ExternalUrl", "Story"]:
|
||||||
return ShareAttachment(
|
rtn = ShareAttachment(
|
||||||
uid=a.get("legacy_attachment_id"),
|
uid=a.get("legacy_attachment_id"),
|
||||||
author=story["target"]["actors"][0]["id"]
|
author=story["target"]["actors"][0]["id"]
|
||||||
if story["target"].get("actors")
|
if story["target"].get("actors")
|
||||||
@@ -191,28 +191,22 @@ def graphql_to_extensible_attachment(a):
|
|||||||
description=story["description"].get("text")
|
description=story["description"].get("text")
|
||||||
if story.get("description")
|
if story.get("description")
|
||||||
else None,
|
else None,
|
||||||
source=story["source"]["text"],
|
source=story["source"].get("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,
|
|
||||||
attachments=[
|
attachments=[
|
||||||
graphql_to_subattachment(attachment)
|
graphql_to_subattachment(attachment)
|
||||||
for attachment in story.get("subattachments")
|
for attachment in story.get("subattachments")
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
if story.get("media"):
|
||||||
|
if story["media"].get("image"):
|
||||||
|
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:
|
else:
|
||||||
return UnsentMessage(uid=a.get("legacy_attachment_id"))
|
return UnsentMessage(uid=a.get("legacy_attachment_id"))
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user