фикс для статичных гиф файлов

This commit is contained in:
Sergey 2020-10-24 21:57:13 +03:00
parent ff88f26e0f
commit 4599018118

View File

@ -992,11 +992,15 @@ async def process_attachment(attachment, token=None):
elif atype == 'doc':
ext = attachment[atype]['ext']
if ext == 'gif':
size = int(attachment[atype]['preview']['video']['file_size'])
gif_url = attachment[atype]['preview']['video']['src']
if size > MAX_FILE_SIZE:
return {'content': f'<a href="{gif_url}">GIF</a>', 'type': 'text'}
return {'content': gif_url, 'type': 'document'}
if 'video' in attachment[atype]['preview']:
size = int(attachment[atype]['preview']['video']['file_size'])
gif_url = attachment[atype]['preview']['video']['src']
if size > MAX_FILE_SIZE:
return {'content': f'<a href="{gif_url}">GIF</a>', 'type': 'text'}
return {'content': gif_url, 'type': 'document'}
else:
photo_url = attachment[atype]['preview']['photo']['sizes'][-1]['src']
return {'content': photo_url, 'type': 'photo'}
# elif 'preview' in attachment[atype] and attachment[atype]['preview'].get('graffiti'):
# graffiti_url = attachment[atype]['preview']['photo']['sizes'][-1]['src']
# with aiohttp.ClientSession() as session: