From d19107de1b95bcaecd5072973957453b4b11f729 Mon Sep 17 00:00:00 2001 From: Eugene P Date: Fri, 15 Dec 2023 19:01:32 +0200 Subject: [PATCH] MS Teams connector - review fixes --- msteams/provider/client.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/msteams/provider/client.py b/msteams/provider/client.py index c61c71311..696713735 100644 --- a/msteams/provider/client.py +++ b/msteams/provider/client.py @@ -119,14 +119,16 @@ async def _prepare_attachment_download_url(self, attachment): def _prepare_attachments(self, messages, results): attachments = [] for message in messages: - if message is not None: - if "attachments" in message: - for attachment in message["attachments"]: - attachment["downloadUrl"] = None - if attachment["contentType"] == "reference": - if "contentUrl" in attachment: - attachments.append(attachment) - results.append(message) + if message is None: + continue + for attachment in message.get("attachments", []): + attachment["downloadUrl"] = None + if ( + attachment["contentType"] == "reference" + and "contentUrl" in attachment + ): + attachments.append(attachment) + results.append(message) if len(attachments) > 0: self.loop.run_until_complete( self._gather_downloadable_attachments(attachments)