summaryrefslogtreecommitdiff
path: root/iris/backend.go
diff options
context:
space:
mode:
authortjpcc <tjp@ctrl-c.club>2023-09-21 08:03:43 -0600
committertjpcc <tjp@ctrl-c.club>2023-09-21 08:03:43 -0600
commitee332003dc19a480cbdd3a15f44d11bb2d6198f9 (patch)
tree76b9eeabee4f495ee633223b71b32e16e7424200 /iris/backend.go
parent985651bbabce5f9d4b8f0e8103610b67db4147ea (diff)
[Posting] use the Subject header as first line when appropriate
h/t ~rocky
Diffstat (limited to 'iris/backend.go')
-rw-r--r--iris/backend.go10
1 files changed, 9 insertions, 1 deletions
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 {