Revert "upload attachments asynchronously"
This reverts commit ec7d7176b0
.
It turns out that Mastodon decides what order to show attachments using the order that they were uploaded, not the order of the media_ids parameter or anything.
This commit is contained in:
parent
ec7d7176b0
commit
173060d2d3
|
@ -169,14 +169,6 @@ async def update_followers(c, me):
|
||||||
else:
|
else:
|
||||||
log('No accounts to unfollow.')
|
log('No accounts to unfollow.')
|
||||||
|
|
||||||
async def upload_image(c, image, desc):
|
|
||||||
card_name = desc.split('\n')[0].split(' - ')[0]
|
|
||||||
log(f'Uploading {card_name}...')
|
|
||||||
id = (await c.upload_attachment(fileobj=image, description=desc))['id']
|
|
||||||
log(f'Done uploading {card_name}!')
|
|
||||||
return id
|
|
||||||
|
|
||||||
|
|
||||||
async def listen(c, me):
|
async def listen(c, me):
|
||||||
log('Listening...')
|
log('Listening...')
|
||||||
async with c.streaming('user') as stream:
|
async with c.streaming('user') as stream:
|
||||||
|
@ -235,9 +227,9 @@ async def listen(c, me):
|
||||||
|
|
||||||
if media:
|
if media:
|
||||||
try:
|
try:
|
||||||
media_ids = await asyncio.gather(
|
media_ids = []
|
||||||
*(upload_image(c, image, desc) for image, desc in media)
|
for image, desc in media:
|
||||||
)
|
media_ids.append((await c.upload_attachment(fileobj=image, params={}, description=desc))['id'])
|
||||||
except atoot.api.RatelimitError:
|
except atoot.api.RatelimitError:
|
||||||
media_ids = None
|
media_ids = None
|
||||||
reply_text += '\n\nMedia attachments are temporarily disabled due to API restrictions, they will return shortly.'
|
reply_text += '\n\nMedia attachments are temporarily disabled due to API restrictions, they will return shortly.'
|
||||||
|
|
Loading…
Reference in New Issue