Added DeletedMessage attachment

This commit is contained in:
Kacper Ziubryniewicz
2018-12-09 14:55:10 +01:00
parent 41bbe18e3d
commit 861f17bc4d
2 changed files with 52 additions and 40 deletions

View File

@@ -131,7 +131,9 @@ def graphql_to_attachment(a):
def graphql_to_extensible_attachment(a):
story = a.get('story_attachment')
if story:
_type = story['target']['__typename']
target = story.get('target')
if target:
_type = target['__typename']
if _type == 'MessageLocation':
latitude, longitude = get_url_parameter(get_url_parameter(story['url'], 'u'), 'where1').split(", ")
rtn = LocationAttachment(
@@ -171,7 +173,11 @@ def graphql_to_extensible_attachment(a):
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=[graphql_to_subattachment(attachment) for attachment in story.get('subattachments')]
attachments=[graphql_to_subattachment(attachment) for attachment in story.get('subattachments')],
)
else:
return DeletedMessage(
uid=a.get('legacy_attachment_id'),
)

View File

@@ -216,6 +216,12 @@ class Attachment(object):
"""Represents a Facebook attachment"""
self.uid = uid
class DeletedMessage(Attachment):
def __init__(self, *args, **kwargs):
"""Represents a deleted message"""
super(DeletedMessage, self).__init__(*args, **kwargs)
class Sticker(Attachment):
#: The sticker-pack's ID
pack = None