From ee332003dc19a480cbdd3a15f44d11bb2d6198f9 Mon Sep 17 00:00:00 2001 From: tjpcc Date: Thu, 21 Sep 2023 08:03:43 -0600 Subject: [Posting] use the Subject header as first line when appropriate h/t ~rocky --- iris/backend.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'iris/backend.go') diff --git a/iris/backend.go b/iris/backend.go index 787db96..7b1c058 100644 --- a/iris/backend.go +++ b/iris/backend.go @@ -249,7 +249,7 @@ func msgToIris(article *nntp.Article) (*irisMsg, error) { var msg irisMsg msg.Data.Author = irisAuthor(article.Header.Get("From")) msg.Data.Timestamp = postTime - msg.Data.Message = string(body) + msg.Data.Message = irisBody(article.Header.Get("Subject"), string(body)) refs := article.Header.Get("References") if refs != "" { spl := strings.SplitN(refs, " ", 2) @@ -266,6 +266,14 @@ func msgToIris(article *nntp.Article) (*irisMsg, error) { return &msg, nil } +func irisBody(subject, body string) string { + firstline, _, _ := strings.Cut(body, "\n") + if subject != "" && subject != firstline { + body = subject + "\n\n" + body + } + return body +} + func irisAuthor(nntpAuthor string) string { addr, err := mail.ParseAddress(nntpAuthor) if err != nil { -- cgit v1.2.3