From d4d06ae48aba9109414257cd9385d795af76068b Mon Sep 17 00:00:00 2001 From: Martin Hebnes Pedersen Date: Fri, 29 Dec 2023 10:59:02 +0100 Subject: [PATCH] Avoid defaults overriding values from form Fixes ignored MsgTo, MsgBcc and other common fields. --- internal/forms/forms.go | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/internal/forms/forms.go b/internal/forms/forms.go index 6cbe317e..10c8a5b7 100644 --- a/internal/forms/forms.go +++ b/internal/forms/forms.go @@ -983,14 +983,20 @@ func (b formMessageBuilder) initFormValues() { b.FormValues["msgsender"] = b.FormsMgr.config.MyCall // some defaults that we can't set yet. Winlink doesn't seem to care about these - b.FormValues["msgto"] = "" - b.FormValues["msgcc"] = "" - b.FormValues["msgsubject"] = "" - b.FormValues["msgbody"] = "" - b.FormValues["msgp2p"] = "" - b.FormValues["msgisforward"] = "False" - b.FormValues["msgisacknowledgement"] = "False" - b.FormValues["msgseqnum"] = "0" + // Set only if they're not set by form values. + for _, key := range []string{"msgto", "msgcc", "msgsubject", "msgbody", "msgp2p"} { + if _, ok := b.FormValues[key]; !ok { + b.FormValues[key] = "" + } + } + for _, key := range []string{"msgisforward", "msgisacknowledgement"} { + if _, ok := b.FormValues[key]; !ok { + b.FormValues[key] = "False" + } + } + if _, ok := b.FormValues["msgseqnum"]; !ok { + b.FormValues["msgseqnum"] = "0" + } } func (b formMessageBuilder) scanTmplBuildMessage(tmplPath string) (MessageForm, error) { @@ -1046,6 +1052,8 @@ func (b formMessageBuilder) scanTmplBuildMessage(tmplPath string) (MessageForm, msgForm.To = strings.TrimSpace(value) case "Cc": msgForm.Cc = strings.TrimSpace(value) + case "Readonly": + // TODO: Disable editing of body in composer? default: if inBody { msgForm.Body += lineTmpl + "\n"