Fix attachment parsing for newer structure
This commit is contained in:
@@ -1482,21 +1482,20 @@ class Client(object):
|
|||||||
try:
|
try:
|
||||||
for a in delta['attachments']:
|
for a in delta['attachments']:
|
||||||
mercury = a['mercury']
|
mercury = a['mercury']
|
||||||
if mercury.get('attach_type'):
|
if mercury.get('blob_attachment'):
|
||||||
image_metadata = a.get('imageMetadata', {})
|
image_metadata = a.get('imageMetadata', {})
|
||||||
attach_type = mercury['attach_type']
|
attach_type = mercury['blob_attachment']['__typename']
|
||||||
if attach_type != 'share':
|
attachment = graphql_to_attachment(mercury.get('blob_attachment', {}))
|
||||||
attachment = graphql_to_attachment(mercury.get('blob_attachment', {}))
|
|
||||||
else:
|
|
||||||
# TODO: Add more data here for shared stuff (URLs, events and so on)
|
|
||||||
pass
|
|
||||||
|
|
||||||
if attach_type == ['file', 'video']:
|
if attach_type == ['MessageFile', 'MessageVideo', 'MessageAudio']:
|
||||||
# TODO: Add more data here for audio files
|
# TODO: Add more data here for audio files
|
||||||
attachment.size = int(a['fileSize'])
|
attachment.size = int(a['fileSize'])
|
||||||
attachments.append(attachment)
|
attachments.append(attachment)
|
||||||
if a['mercury'].get('sticker_attachment'):
|
elif mercury.get('sticker_attachment'):
|
||||||
sticker = graphql_to_sticker(a['mercury']['sticker_attachment'])
|
sticker = graphql_to_sticker(a['mercury']['sticker_attachment'])
|
||||||
|
elif mercury.get('extensible_attachment'):
|
||||||
|
# TODO: Add more data here for shared stuff (URLs, events and so on)
|
||||||
|
pass
|
||||||
except Exception:
|
except Exception:
|
||||||
log.exception('An exception occured while reading attachments: {}'.format(delta['attachments']))
|
log.exception('An exception occured while reading attachments: {}'.format(delta['attachments']))
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user