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"),
|
||||
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
|
||||
|
||||
|
||||
def graphql_to_subattachment(a):
|
||||
_type = a["target"]["__typename"]
|
||||
def graphql_to_subattachment(data):
|
||||
_type = data["target"]["__typename"]
|
||||
if _type == "Video":
|
||||
media = a["media"]
|
||||
return VideoAttachment(
|
||||
duration=media.get("playable_duration_in_ms"),
|
||||
preview_url=media.get("playable_url"),
|
||||
medium_image=media.get("image"),
|
||||
uid=a["target"].get("video_id"),
|
||||
)
|
||||
return VideoAttachment._from_subattachment(data)
|
||||
|
||||
return None
|
||||
|
||||
|
||||
def graphql_to_quick_reply(q, is_response=False):
|
||||
|
Reference in New Issue
Block a user