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 kanazawa.. (unknown [101.128.126.198]) by gnuweeb.org (Postfix) with ESMTPSA id C20CE80632; Fri, 4 Nov 2022 18:09:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1667585383; bh=kTXduCFa/fdjNMmL3l4ZlqJa+M536c4gcc7fNn7jol8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D3z7H6lw1MzBII4YdCWwB0BknQ+ls4UG97D79zLpIYhNDRs7MYu7AGFG4DBsI2PUU J4Nw2k2XSisOPu6uUmyCH5esJI6ip/yEva+PIs37RkoMloI0vFmp3wrat4cSxX46Nr Jqydak2R5oT8J1MHCGFRnemHaL8+F6ye8pq2Q4Ps4ftFHqejQL170ZHW/u+6KGTd5u 4eNIh960KhQVf0NP58gUuu+3BVADHqzmxLd+1Xaq94OJS4bFwyXKrYYsJRoEzJQ4Yh jbMllFhunLOeoG40yQ2HQSfpEjWBGa7BdxJpIzuc4C1HMcLVrTeuX1F8DGKPWTNxRo qRRSdD9WQ2U5Q== From: Muhammad Rizki To: Ammar Faizi Cc: Muhammad Rizki , Alviro Iskandar Setiawan , GNU/Weeb Mailing List Subject: [PATCH v1 02/16] fix: utils: Fix the extract_list() utility function Date: Sat, 5 Nov 2022 01:09:09 +0700 Message-Id: <20221104180931.3852-3-kiizuha@gnuweeb.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221104180931.3852-1-kiizuha@gnuweeb.org> References: <20221104180931.3852-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 03453b4..88ce128 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