feat(qsl): credit line at the foot of the default QSL e-mail

"Designed & sent by OpsLog — https://github.com/GregTroar/OpsLog/releases/latest"
now closes the default body, so a fresh install sends it without being asked.

Put in the TEMPLATE, not appended at send time. Two consequences, both of them
the point: an operator who does not want it deletes the line once and it is
gone, and one who has already written their own body never sees it appear —
a stored template is returned verbatim and the default is only the fallback.
Appending it at send would have made it unremovable, which is not a thing to do
to somebody's outgoing mail.

The link is the human release page. updateCheckURL sits next to it in update.go
and answers JSON, which is the easy mistake here — a correspondent who clicks
the credit gets a download page, and a test says so.
This commit is contained in:
2026-08-16 11:07:06 +02:00
parent 46d6531cf5
commit c0dc1bfcc4
4 changed files with 62 additions and 5 deletions
+39
View File
@@ -0,0 +1,39 @@
package main
import (
"strings"
"testing"
)
// The default QSL e-mail closes with a credit line carrying the download page.
//
// It is part of the BODY TEMPLATE, deliberately: an operator who does not want
// it deletes it once, and one who already wrote their own body never sees it,
// because a stored template is returned verbatim and the default is only the
// fallback. Appending it at send time would have made it unremovable.
func TestQSLCreditIsInTheDefaultBody(t *testing.T) {
if !strings.HasSuffix(defaultQSLEmailBody, qslCredit) {
t.Errorf("the default QSL e-mail does not end with the credit line:\n%q", defaultQSLEmailBody)
}
// The body still has to be a usable template — the credit is added to it,
// not in place of it.
for _, v := range []string{"{DATE}", "{BAND}", "{MODE}", "{MYCALL}"} {
if !strings.Contains(defaultQSLEmailBody, v) {
t.Errorf("the default QSL e-mail lost %s", v)
}
}
}
// The link must be the page a person can read. updateCheckURL sits beside it and
// answers JSON — sending a correspondent there is the easy mistake to make.
func TestQSLCreditLinksTheHumanPage(t *testing.T) {
if !strings.Contains(qslCredit, releasesPageURL) {
t.Errorf("credit %q does not carry the releases page", qslCredit)
}
if strings.Contains(qslCredit, "api.github.com") {
t.Errorf("credit %q points at the update API, which answers JSON to whoever clicks it", qslCredit)
}
if !strings.Contains(qslCredit, "OpsLog") {
t.Errorf("credit %q does not name OpsLog", qslCredit)
}
}