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 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 4E9158191C; Mon, 19 Dec 2022 23:57:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1671494272; bh=X03D/mi3OzmLiL6CS9arZ3V8sqTWKxHeUFfD0tHL804=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ICmY5uUphqhqPRsxBRXSgBdzSVvmbH/69A83BQl5WH8NHO4rTNBNQPMVnvrDThebv 1MBfd3qkhEPNLIG4GDRWmNAiYNzlvPCitbiJwWIMZl9Qoz6bTP+Af4UMFJxw7i3CO9 g38s/ll8cidCAVvA82Xi5/lx/PCQBXKbtAFHRqsyzMiWSdhkHwns079yGM+B3ad1Tm 6xg+5IkXGpn1cXZDPg7fzXWHH/kgKFw0EhgD/VymATqjggGiAqQJD2ytgdMVEFIX1R wnPN6RK4p6dJOiPJMnyRfOQl3PnFUqS2RtfHb5RW+z0o8OjKbfKW54+m630JlE1s/3 OyXuj7/Vtvqug== From: Muhammad Rizki To: Ammar Faizi Cc: Muhammad Rizki , Alviro Iskandar Setiawan , GNU/Weeb Mailing List Subject: [PATCH v3 04/17] fix: utils: Fix the extract_list() utility function Date: Tue, 20 Dec 2022 06:57:08 +0700 Message-Id: <20221219235721.126-5-kiizuha@gnuweeb.org> X-Mailer: git-send-email 2.34.1.windows.1 In-Reply-To: <20221219235721.126-1-kiizuha@gnuweeb.org> References: <20221219235721.126-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 0ba649a..c5f6a00 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