Move attachment and subattachment dispatching to _file.py

This commit is contained in:
Mads Marquart
2019-03-10 19:26:01 +01:00
parent 0b99238676
commit 53856a3622
5 changed files with 28 additions and 28 deletions

View File

@@ -3,6 +3,7 @@
from __future__ import unicode_literals
import json
import re
from . import _file
from .models import *
from ._util import *
@@ -27,20 +28,6 @@ class ConcatJSONDecoder(json.JSONDecoder):
# End shameless copy
def graphql_to_attachment(a):
_type = a["__typename"]
if _type in ["MessageImage", "MessageAnimatedImage"]:
return ImageAttachment._from_graphql(a)
elif _type == "MessageVideo":
return VideoAttachment._from_graphql(a)
elif _type == "MessageAudio":
return AudioAttachment._from_graphql(a)
elif _type == "MessageFile":
return FileAttachment._from_graphql(a)
else:
return Attachment(uid=a.get("legacy_attachment_id"))
def graphql_to_extensible_attachment(a):
story = a.get("story_attachment")
if not story:
@@ -61,14 +48,6 @@ def graphql_to_extensible_attachment(a):
return None
def graphql_to_subattachment(data):
_type = data["target"]["__typename"]
if _type == "Video":
return VideoAttachment._from_subattachment(data)
return None
def graphql_to_quick_reply(q, is_response=False):
data = dict()
_type = q.get("content_type").lower()
@@ -122,7 +101,7 @@ def graphql_to_message(message):
}
if message.get("blob_attachments") is not None:
rtn.attachments = [
graphql_to_attachment(attachment)
_file.graphql_to_attachment(attachment)
for attachment in message["blob_attachments"]
]
if message.get("platform_xmd_encoded"):