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 50C598148E; Fri, 4 Nov 2022 18:09:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1667585385; bh=RidSn76rIRyUxWnwYT8mBMDRZv4cir9mFFf058kxq/A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W1b7VQeT4XZTXMpsRjVAf3ONOhohaDfk9X3NnKTGsbBLFkLvMhomHKH4Cc67UKdga pcdNOxgbJjHSUNb7jLu+N5sKk//Pl9E683gJ9ClO4vwZRNlrk6Rafz5a5hETkWxgXk utHO12b4iyJzlPyBP4/aKSC1hV8NRi8VUXLLGb56wBQ2cQOFWjzxzHmyMB3sA/KUM0 IQ7G5Mmd7P2rb31b8+R9OOtvdZogk+PAwKfe8V0RbXFIFTsCyXzI7LY+Yv7H/vTVXJ 7Qb2/BRY5dqVgnzYXVljyjPH0EfHf32Elo9/fgwO7+SE+KO1SsvacAIw2Y43ZM0qZ3 zqQdSyqKldPmQ== From: Muhammad Rizki To: Ammar Faizi Cc: Muhammad Rizki , Alviro Iskandar Setiawan , GNU/Weeb Mailing List Subject: [PATCH v1 03/16] utils: Change on max for TO/CC header list Date: Sat, 5 Nov 2022 01:09:10 +0700 Message-Id: <20221104180931.3852-4-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: Telegram media caption is limited to 1024 char length, set the max list to 15 to avoid MediaCaptionTooLong error. Signed-off-by: Muhammad Rizki --- daemon/atom/utils.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/daemon/atom/utils.py b/daemon/atom/utils.py index 88ce128..b807f7b 100644 --- a/daemon/atom/utils.py +++ b/daemon/atom/utils.py @@ -96,8 +96,17 @@ def extract_list(key: str, thread: Message): return __extract_list(people) -def consruct_to_n_cc(to: list, cc: list): +def consruct_to_n_cc( + to: list, + cc: list, + is_patch: bool, + platform: Platform.TELEGRAM +): NR_MAX_LIST = 20 + if platform == Platform.TELEGRAM and is_patch: + # Telegram caption limited to 1024 + # so set max to 15 + NR_MAX_LIST = 15 n = 0 ret = "" @@ -195,12 +204,13 @@ def create_template(thread: Message, platform: Platform, to=None, cc=None): border = f"\n{'-'*80}" subject = thread.get('subject') + content, files = extract_body(thread, platform) + is_patch = __is_patch(subject, content) + ret = f"From: {thread.get('from')}\n" - ret += consruct_to_n_cc(to, cc) + ret += consruct_to_n_cc(to, cc, is_patch, platform) ret += f"Date: {thread.get('date')}\n" ret += f"Subject: {subject}\n\n" - content, files = extract_body(thread, platform) - is_patch = __is_patch(subject, content) if is_patch: ret += content -- Muhammad Rizki