diff --git a/internal/extsvc/clublog.go b/internal/extsvc/clublog.go index c0719a2..66bce77 100644 --- a/internal/extsvc/clublog.go +++ b/internal/extsvc/clublog.go @@ -27,6 +27,14 @@ const clublogBatchURL = "https://clublog.org/putlogs.php" // must send a real, app-identifying User-Agent. const clublogUserAgent = "OpsLog/1.0 (+https://github.com/GregTroar/OpsLog)" +// looksLikeHTML reports a body that is a web page rather than an answer. Club +// Log serves its normal site for refusals and blocks, so this is what separates +// "here is what went wrong" from 4 KB of markup an operator cannot act on. +func looksLikeHTML(s string) bool { + l := strings.ToLower(strings.TrimSpace(s)) + return strings.HasPrefix(l, " 200 { msg = msg[:200] + "…" } diff --git a/internal/extsvc/clublog_test.go b/internal/extsvc/clublog_test.go new file mode 100644 index 0000000..709f592 --- /dev/null +++ b/internal/extsvc/clublog_test.go @@ -0,0 +1,26 @@ +package extsvc + +import "testing" + +// Club Log answers a refused login with its ordinary web page. The operator must +// get a sentence they can act on, not four kilobytes of markup — that was the +// first thing reported once the test started working at all. +func TestLooksLikeHTML(t *testing.T) { + cases := []struct { + body string + want bool + }{ + {"\n…403 - Access denied…", true}, + {"