From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on gnuweeb.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NO_DNS_FOR_FROM,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 Received: from localhost.localdomain (unknown [101.128.125.209]) by gnuweeb.org (Postfix) with ESMTPSA id 3E586819C5; Wed, 21 Dec 2022 01:34:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1671586459; bh=roEhqNSYrZGpMKywn44Sy+Bm01zkAlW8GPmFN1Ic6t8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KPGCKNexlyRU4MLF0HdPxxl9+nvtwPeRJXpHRlV++iZD6VDfSBUM3ApFqh9WRj/iA ZU04F+jpYp2m6FL8Uwb5M0gaX6zESN7UesD7wTp3/pR6n5Zi6Bqn4vh9iExUZY8Fx5 ayy6560Lr7PfEfknVNrv2djBn29YOhIrp4/a1azfIy1Qj+WKEmPmiYgbEpjl/e0Qwd ZjKB3WNGW+OTvmcLPvvc83bG1oAs3s7St55I2JH23+D9D6wTt7kZUpfhOCPQZIYTHv KAQQsKtdPjlHhP4RaOZyQIBh9k/Tx1XzvMPDvZrtToa5TkPvsrlast02FvYbMMbnpt KaHXjAQIfpMsQ== From: Muhammad Rizki To: Ammar Faizi Cc: Muhammad Rizki , Alviro Iskandar Setiawan , GNU/Weeb Mailing List Subject: [PATCH v4 04/17] fix: utils: Fix the extract_list() utility function Date: Wed, 21 Dec 2022 08:33:34 +0700 Message-Id: <20221221013347.1704-5-kiizuha@gnuweeb.org> X-Mailer: git-send-email 2.34.1.windows.1 In-Reply-To: <20221221013347.1704-1-kiizuha@gnuweeb.org> References: <20221221013347.1704-1-kiizuha@gnuweeb.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Fix the extract_list() when the `payload.get()` header function is not retrieving the header value instead of throwing error. Simple error log says: AttributeError: 'Group' object has no attribute 'local_part' Source problem: https://s.id/1n1C6 (shorted lore email URL) Signed-off-by: Muhammad Rizki --- daemon/atom/utils.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/daemon/atom/utils.py b/daemon/atom/utils.py index ed59812..4f9b9b5 100644 --- a/daemon/atom/utils.py +++ b/daemon/atom/utils.py @@ -86,9 +86,12 @@ def __extract_list(ss): return ret -def extract_list(key: str, content: Dict[str, str]): - people = content.get(key.lower()) - if not people: +def extract_list(key: str, thread: Message): + try: + people = thread.get(key.lower()) + if not people: + return [] + except: return [] return __extract_list(people) -- Muhammad Rizki