ignore incomplete thumbnail info

This commit is contained in:
Morgan McMillian 2020-12-17 20:38:27 -08:00
parent 25ac47d049
commit b65b040a15

View file

@ -258,15 +258,16 @@ def raw_from_event(event):
else: else:
value['height'] = 200 value['height'] = 200
if 'thumbnail_info' in event['content']['info']: if 'thumbnail_info' in event['content']['info']:
value['thumbnail_url'] = app.config['MATRIX_URL'] + '/_matrix/media/r0/download/' + event['content']['info']['thumbnail_url'][6:] if 'thumbnail_url' in event['content']['info']:
if 'w' in event['content']['info']['thumbnail_info']: value['thumbnail_url'] = app.config['MATRIX_URL'] + '/_matrix/media/r0/download/' + event['content']['info']['thumbnail_url'][6:]
value['thumbnail_width'] = event['content']['info']['thumbnail_info']['w'] if 'w' in event['content']['info']['thumbnail_info']:
else: value['thumbnail_width'] = event['content']['info']['thumbnail_info']['w']
value['thumbnail_width'] = 200 else:
if 'h' in event['content']['info']['thumbnail_info']: value['thumbnail_width'] = 200
value['thumbnail_height'] = event['content']['info']['thumbnail_info']['h'] if 'h' in event['content']['info']['thumbnail_info']:
else: value['thumbnail_height'] = event['content']['info']['thumbnail_info']['h']
value['thumbnail_height'] = 200 else:
value['thumbnail_height'] = 200
elif event['content']['msgtype'] == 'm.video': elif event['content']['msgtype'] == 'm.video':
# TODO: Need to sort out the oembed for this media type # TODO: Need to sort out the oembed for this media type