Add author name in thread

This commit is contained in:
Romain de Laage 2021-03-01 18:32:43 +01:00
parent 4ebfcd27f1
commit c9fabd4967
Signed by: rdelaage
GPG Key ID: 534845FADDF0C329
1 changed files with 7 additions and 6 deletions

View File

@ -18,9 +18,10 @@ import (
)
type Blog struct {
Id string `json:"id"`
Content string `json:"content"`
Date string `json:"created_at"`
Id string `json:"id"`
Content string `json:"content"`
Date string `json:"created_at"`
Author Account `json:"account"`
}
type Config struct {
@ -281,7 +282,7 @@ func printThread(conn *tls.Conn, baseURL, tootID string) {
// Print each anscestor
for _, toot := range thread.Ancestors {
_, err = fmt.Fprintf(conn, "\n```\n* Posted on " + toot.Date + " *\n```\n" + removeHTMLTags(toot.Content) + "\n")
_, err = fmt.Fprintf(conn, "\n```\n* Posted on " + toot.Date + " by " + toot.Author.Name + " *\n```\n" + removeHTMLTags(toot.Content) + "\n")
if err != nil {
log.Println("handleConn: %s", err)
return
@ -289,7 +290,7 @@ func printThread(conn *tls.Conn, baseURL, tootID string) {
}
// Print original toot
_, err = fmt.Fprintf(conn, "\n# Toot\n\n```\n* Posted on " + originalToot.Date + " *\n```\n" + removeHTMLTags(originalToot.Content) + "\n")
_, err = fmt.Fprintf(conn, "\n# Toot\n\n```\n* Posted on " + originalToot.Date + " by "+ originalToot.Author.Name +" *\n```\n" + removeHTMLTags(originalToot.Content) + "\n")
if err != nil {
log.Println("handleConn: %s", err)
return
@ -302,7 +303,7 @@ func printThread(conn *tls.Conn, baseURL, tootID string) {
return
}
for _, toot := range thread.Descendants {
_, err = fmt.Fprintf(conn, "\n```\n* Posted on " + toot.Date + " *\n```\n" + removeHTMLTags(toot.Content) + "\n")
_, err = fmt.Fprintf(conn, "\n```\n* Posted on " + toot.Date + " by " + toot.Author.Name + " *\n```\n" + removeHTMLTags(toot.Content) + "\n")
if err != nil {
log.Println("handleConn: %s", err)
return