Added DeletedMessage attachment
This commit is contained in:
@@ -131,47 +131,53 @@ def graphql_to_attachment(a):
|
|||||||
def graphql_to_extensible_attachment(a):
|
def graphql_to_extensible_attachment(a):
|
||||||
story = a.get('story_attachment')
|
story = a.get('story_attachment')
|
||||||
if story:
|
if story:
|
||||||
_type = story['target']['__typename']
|
target = story.get('target')
|
||||||
if _type == 'MessageLocation':
|
if target:
|
||||||
latitude, longitude = get_url_parameter(get_url_parameter(story['url'], 'u'), 'where1').split(", ")
|
_type = target['__typename']
|
||||||
rtn = LocationAttachment(
|
if _type == 'MessageLocation':
|
||||||
uid=int(story['deduplication_key']),
|
latitude, longitude = get_url_parameter(get_url_parameter(story['url'], 'u'), 'where1').split(", ")
|
||||||
latitude=float(latitude),
|
rtn = LocationAttachment(
|
||||||
longitude=float(longitude),
|
uid=int(story['deduplication_key']),
|
||||||
)
|
latitude=float(latitude),
|
||||||
rtn.image_url = story['media']['image']['uri']
|
longitude=float(longitude),
|
||||||
rtn.image_width = story['media']['image']['width']
|
)
|
||||||
rtn.image_height = story['media']['image']['height']
|
rtn.image_url = story['media']['image']['uri']
|
||||||
rtn.url = story['url']
|
rtn.image_width = story['media']['image']['width']
|
||||||
return rtn
|
rtn.image_height = story['media']['image']['height']
|
||||||
elif _type == 'MessageLiveLocation':
|
rtn.url = story['url']
|
||||||
rtn = LiveLocationAttachment(
|
return rtn
|
||||||
uid=int(story['target']['live_location_id']),
|
elif _type == 'MessageLiveLocation':
|
||||||
latitude=story['target']['coordinate']['latitude'] if story['target'].get('coordinate') else None,
|
rtn = LiveLocationAttachment(
|
||||||
longitude=story['target']['coordinate']['longitude'] if story['target'].get('coordinate') else None,
|
uid=int(story['target']['live_location_id']),
|
||||||
name=story['title_with_entities']['text'],
|
latitude=story['target']['coordinate']['latitude'] if story['target'].get('coordinate') else None,
|
||||||
expiration_time=story['target']['expiration_time'] if story['target'].get('expiration_time') else None,
|
longitude=story['target']['coordinate']['longitude'] if story['target'].get('coordinate') else None,
|
||||||
is_expired=story['target']['is_expired'],
|
name=story['title_with_entities']['text'],
|
||||||
)
|
expiration_time=story['target']['expiration_time'] if story['target'].get('expiration_time') else None,
|
||||||
rtn.image_url = story['media']['image']['uri']
|
is_expired=story['target']['is_expired'],
|
||||||
rtn.image_width = story['media']['image']['width']
|
)
|
||||||
rtn.image_height = story['media']['image']['height']
|
rtn.image_url = story['media']['image']['uri']
|
||||||
rtn.url = story['url']
|
rtn.image_width = story['media']['image']['width']
|
||||||
return rtn
|
rtn.image_height = story['media']['image']['height']
|
||||||
elif _type in ['ExternalUrl', 'Story']:
|
rtn.url = story['url']
|
||||||
return ShareAttachment(
|
return rtn
|
||||||
|
elif _type in ['ExternalUrl', 'Story']:
|
||||||
|
return ShareAttachment(
|
||||||
|
uid=a.get('legacy_attachment_id'),
|
||||||
|
author=story['target']['actors'][0]['id'] if story['target'].get('actors') else None,
|
||||||
|
url=story['url'],
|
||||||
|
original_url=get_url_parameter(story['url'], 'u') if "/l.php?u=" in story['url'] else story['url'],
|
||||||
|
title=story['title_with_entities'].get('text'),
|
||||||
|
description=story['description'].get('text'),
|
||||||
|
source=story['source']['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=[graphql_to_subattachment(attachment) for attachment in story.get('subattachments')],
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
return DeletedMessage(
|
||||||
uid=a.get('legacy_attachment_id'),
|
uid=a.get('legacy_attachment_id'),
|
||||||
author=story['target']['actors'][0]['id'] if story['target'].get('actors') else None,
|
|
||||||
url=story['url'],
|
|
||||||
original_url=get_url_parameter(story['url'], 'u') if "/l.php?u=" in story['url'] else story['url'],
|
|
||||||
title=story['title_with_entities'].get('text'),
|
|
||||||
description=story['description'].get('text'),
|
|
||||||
source=story['source']['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=[graphql_to_subattachment(attachment) for attachment in story.get('subattachments')]
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@@ -216,6 +216,12 @@ class Attachment(object):
|
|||||||
"""Represents a Facebook attachment"""
|
"""Represents a Facebook attachment"""
|
||||||
self.uid = uid
|
self.uid = uid
|
||||||
|
|
||||||
|
class DeletedMessage(Attachment):
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
"""Represents a deleted message"""
|
||||||
|
super(DeletedMessage, self).__init__(*args, **kwargs)
|
||||||
|
|
||||||
class Sticker(Attachment):
|
class Sticker(Attachment):
|
||||||
#: The sticker-pack's ID
|
#: The sticker-pack's ID
|
||||||
pack = None
|
pack = None
|
||||||
|
Reference in New Issue
Block a user