From 15415a5eec256789e4031acf991d6af33f756f5e Mon Sep 17 00:00:00 2001 From: Andrew Ferrazzutti Date: Tue, 29 Mar 2022 03:25:38 -0400 Subject: [PATCH] Send multiphoto messages in order --- matrix_appservice_kakaotalk/portal.py | 48 +++++++++++++-------------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/matrix_appservice_kakaotalk/portal.py b/matrix_appservice_kakaotalk/portal.py index 596ac90..a2f573a 100644 --- a/matrix_appservice_kakaotalk/portal.py +++ b/matrix_appservice_kakaotalk/portal.py @@ -1050,7 +1050,7 @@ class Portal(DBPortal, BasePortal): source, intent, attachment, timestamp, message_text )) - def _handle_remote_multiphoto( + async def _handle_remote_multiphoto( self, source: u.User, intent: IntentAPI, @@ -1059,30 +1059,28 @@ class Portal(DBPortal, BasePortal): message_text: str | None, ) -> Awaitable[list[EventID]]: # TODO Upload media concurrently, but post messages sequentially - return asyncio.gather( - *[ - self._handle_remote_uniphoto( - source, intent, - PhotoAttachment( - shout=attachment.shout, - mentions=attachment.mentions, - urls=attachment.urls, - url=attachment.imageUrls[i], - s=attachment.sl[i], - k=attachment.kl[i], - w=attachment.wl[i], - h=attachment.hl[i], - thumbnailUrl=attachment.thumbnailUrls[i], - thumbnailWidth=attachment.thumbnailWidths[i], - thumbnailHeight=attachment.thumbnailHeights[i], - cs=attachment.csl[i], - mt=attachment.mtl[i], - ), - timestamp, message_text, - ) - for i in range(len(attachment.imageUrls)) - ] - ) + return [ + await self._handle_remote_uniphoto( + source, intent, + PhotoAttachment( + shout=attachment.shout, + mentions=attachment.mentions, + urls=attachment.urls, + url=attachment.imageUrls[i], + s=attachment.sl[i], + k=attachment.kl[i], + w=attachment.wl[i], + h=attachment.hl[i], + thumbnailUrl=attachment.thumbnailUrls[i], + thumbnailWidth=attachment.thumbnailWidths[i], + thumbnailHeight=attachment.thumbnailHeights[i], + cs=attachment.csl[i], + mt=attachment.mtl[i], + ), + timestamp, message_text, + ) + for i in range(len(attachment.imageUrls)) + ] def _handle_remote_uniphoto( self,