From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 4536B1FF15F for ; Mon, 7 Oct 2024 18:11:07 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id B76168E6C; Mon, 7 Oct 2024 18:11:32 +0200 (CEST) Date: Mon, 7 Oct 2024 18:11:28 +0200 From: Stoiko Ivanov To: Christoph Heiss Message-ID: <20241007181128.1de3e3b2@rosa.proxmox.com> In-Reply-To: <20241007103214.1006844-2-c.heiss@proxmox.com> References: <20241007103214.1006844-1-c.heiss@proxmox.com> <20241007103214.1006844-2-c.heiss@proxmox.com> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.072 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: Re: [pmg-devel] [PATCH pmg-api v2 1/2] utils: allow specifying plain and/or html for finalize_report() X-BeenThere: pmg-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Mail Gateway development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pmg-devel@lists.proxmox.com Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pmg-devel-bounces@lists.proxmox.com Sender: "pmg-devel" Thanks for the quick turn-around on this! on a quick glance - I think I like the approach (and that you converted all call-sites of finalize_report directly) - however one pitfall/suggestion inline: On Mon, 7 Oct 2024 12:32:11 +0200 Christoph Heiss wrote: > To support both plain-text and HTML emails when sending reports, > PMG::Utils::finalize_report() first needs a small adaption to allow > specifying either only an HTML template or both. > > Suggested-by: Stoiko Ivanov > Signed-off-by: Christoph Heiss > --- > src/PMG/Backup.pm | 2 +- > src/PMG/CLI/pmgqm.pm | 5 ++++- > src/PMG/CLI/pmgreport.pm | 5 ++++- > src/PMG/Utils.pm | 26 +++++++++++++++++++++----- > 4 files changed, 30 insertions(+), 8 deletions(-) > > diff --git a/src/PMG/Backup.pm b/src/PMG/Backup.pm > index ab7e628..e9c116b 100644 > --- a/src/PMG/Backup.pm > +++ b/src/PMG/Backup.pm > @@ -418,7 +418,7 @@ sub send_backup_notification { > my $tt = PMG::Config::get_template_toolkit(); > > my $mailfrom = "Proxmox Mail Gateway "; > - PMG::Utils::finalize_report($tt, 'backup-notification.tt', $vars, $mailfrom, $email); > + PMG::Utils::finalize_report($tt, $vars, $mailfrom, $email, html => 'backup-notification.tt'); I think using a hashref here would help to cause less confusion in the future: PMG::Utils::finalize_report($tt, $vars, $mailfrom, $email, { html => 'backup-notification.tt'} ); (but looking through our source am not 100% sure if we have a strong rule for this) your line above is syntactically equivalent to: PMG::Utils::finalize_report($tt, $vars, $mailfrom, $email, "html", 'backup-notification.tt'); see: https://perldoc.perl.org/perlop#Comma-Operator which I find confusing (especially if I touch this code in the future) since finalize_report is called from quite a few places - I think having those parameters in a hashref would be more robust, but maybe I'm overlooking something? _______________________________________________ pmg-devel mailing list pmg-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pmg-devel