From: Stoiko Ivanov <s.ivanov@proxmox.com>
To: Christoph Heiss <c.heiss@proxmox.com>
Cc: pmg-devel@lists.proxmox.com
Subject: Re: [pmg-devel] [PATCH pmg-api v2 1/2] utils: allow specifying plain and/or html for finalize_report()
Date: Mon, 7 Oct 2024 18:11:28 +0200 [thread overview]
Message-ID: <20241007181128.1de3e3b2@rosa.proxmox.com> (raw)
In-Reply-To: <20241007103214.1006844-2-c.heiss@proxmox.com>
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 <c.heiss@proxmox.com> 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 <s.ivanov@proxmox.com>
> Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
> ---
> 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 <postmaster>";
> - 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
next prev parent reply other threads:[~2024-10-07 16:11 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-07 10:32 [pmg-devel] [PATCH pmg-api v2 0/2] fix #4211: convert quarantine link mail to template Christoph Heiss
2024-10-07 10:32 ` [pmg-devel] [PATCH pmg-api v2 1/2] utils: allow specifying plain and/or html for finalize_report() Christoph Heiss
2024-10-07 16:11 ` Stoiko Ivanov [this message]
2024-10-08 9:34 ` Christoph Heiss
2024-10-07 10:32 ` [pmg-devel] [PATCH pmg-api v2 2/2] fix #4211: convert quarantine link mail to template Christoph Heiss
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241007181128.1de3e3b2@rosa.proxmox.com \
--to=s.ivanov@proxmox.com \
--cc=c.heiss@proxmox.com \
--cc=pmg-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox