Move subattachment parsing to the respective models
This commit is contained in:
@@ -241,3 +241,13 @@ class VideoAttachment(Attachment):
|
|||||||
large_image=data.get("large_image"),
|
large_image=data.get("large_image"),
|
||||||
uid=data.get("legacy_attachment_id"),
|
uid=data.get("legacy_attachment_id"),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _from_subattachment(cls, data):
|
||||||
|
media = data["media"]
|
||||||
|
return cls(
|
||||||
|
duration=media.get("playable_duration_in_ms"),
|
||||||
|
preview_url=media.get("playable_url"),
|
||||||
|
medium_image=media.get("image"),
|
||||||
|
uid=data["target"].get("video_id"),
|
||||||
|
)
|
||||||
|
@@ -61,16 +61,12 @@ def graphql_to_extensible_attachment(a):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def graphql_to_subattachment(a):
|
def graphql_to_subattachment(data):
|
||||||
_type = a["target"]["__typename"]
|
_type = data["target"]["__typename"]
|
||||||
if _type == "Video":
|
if _type == "Video":
|
||||||
media = a["media"]
|
return VideoAttachment._from_subattachment(data)
|
||||||
return VideoAttachment(
|
|
||||||
duration=media.get("playable_duration_in_ms"),
|
return None
|
||||||
preview_url=media.get("playable_url"),
|
|
||||||
medium_image=media.get("image"),
|
|
||||||
uid=a["target"].get("video_id"),
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def graphql_to_quick_reply(q, is_response=False):
|
def graphql_to_quick_reply(q, is_response=False):
|
||||||
|
Reference in New Issue
Block a user