From 2dcc83efda3efd61dffc75324e434ef32d322b8f Mon Sep 17 00:00:00 2001 From: Michael Walle Date: Sun, 11 Feb 2024 16:58:13 +0100 Subject: templates: use email address as fallback If replying to mail or forwarding a mail that doesn't have a recipient name, the automatically generated header line will just have an empty value. Use the names template to extract either the name if available otherwise the mbox name. While at it, instead of just taking the first item of the list, join all items to avoid an index error if the list is empty. Signed-off-by: Michael Walle Acked-by: Robin Jarry --- templates/forward_as_body | 2 +- templates/quoted_reply | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'templates') diff --git a/templates/forward_as_body b/templates/forward_as_body index 5155fab2..3b27db0d 100644 --- a/templates/forward_as_body +++ b/templates/forward_as_body @@ -1,6 +1,6 @@ X-Mailer: aerc {{version}} -Forwarded message from {{(index .OriginalFrom 0).Name}} on {{dateFormat .OriginalDate "Mon Jan 2, 2006 at 3:04 PM"}}: +Forwarded message from {{.OriginalFrom | names | join ", "}} on {{dateFormat .OriginalDate "Mon Jan 2, 2006 at 3:04 PM"}}: {{.OriginalText}} {{- with .Signature }} diff --git a/templates/quoted_reply b/templates/quoted_reply index c08a44d8..1e7ebfae 100644 --- a/templates/quoted_reply +++ b/templates/quoted_reply @@ -1,6 +1,6 @@ X-Mailer: aerc {{version}} -On {{dateFormat (.OriginalDate | toLocal) "Mon Jan 2, 2006 at 3:04 PM MST"}}, {{(index .OriginalFrom 0).Name}} wrote: +On {{dateFormat (.OriginalDate | toLocal) "Mon Jan 2, 2006 at 3:04 PM MST"}}, {{.OriginalFrom | names | join ", "}} wrote: {{trimSignature .OriginalText | quote}} {{- with .Signature }} -- cgit