From 8fb0733908cbb9a3ea0b854950bba86fa553c1f0 Mon Sep 17 00:00:00 2001 From: Jason Streifling Date: Sun, 1 Dec 2024 09:59:39 +0100 Subject: [PATCH] Make atom feed compatible with multiple authors --- cmd/backend/atom.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/cmd/backend/atom.go b/cmd/backend/atom.go index c8d9d1f..4b4b685 100644 --- a/cmd/backend/atom.go +++ b/cmd/backend/atom.go @@ -51,12 +51,18 @@ func GenerateAtomFeed(c *Config, db *DB) (*string, error) { entry.Links[linkID].Type = "image/webp" } - user, err := db.GetUser(c, article.AuthorID) + authors, err := db.GetArticleAuthors(c, article.ID) if err != nil { - return nil, fmt.Errorf("error getting user info for Atom feed: %v", err) + return nil, fmt.Errorf("error getting article's authors for Atom feed: %v", err) + } + for _, author := range authors { + user, err := db.GetUser(c, author.ID) + if err != nil { + return nil, fmt.Errorf("error getting user info for Atom feed: %v", err) + } + authorID := entry.AddAuthor(atom.NewPerson(user.FirstName + " " + user.LastName)) + entry.Authors[authorID].URI = c.Domain + "/image/serve/" + user.ProfilePicLink } - authorID := entry.AddAuthor(atom.NewPerson(user.FirstName + " " + user.LastName)) - entry.Authors[authorID].URI = c.Domain + "/image/serve/" + user.ProfilePicLink tags, err := db.GetArticleTags(article.ID) if err != nil {