From 8d41caf40ad699b829b1b4bc2d8616fb7c175ca3 Mon Sep 17 00:00:00 2001 From: Jason Streifling Date: Sun, 1 Dec 2024 10:04:42 +0100 Subject: [PATCH] Make issue compatible with multiple authors --- cmd/frontend/issues.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/cmd/frontend/issues.go b/cmd/frontend/issues.go index fcb4c45..171ac9d 100644 --- a/cmd/frontend/issues.go +++ b/cmd/frontend/issues.go @@ -33,7 +33,6 @@ func PublishLatestIssue(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFun Published: true, Rejected: false, Created: time.Now(), - AuthorID: session.Values["id"].(int64), AutoGenerated: true, } @@ -49,6 +48,22 @@ func PublishLatestIssue(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFun return } + authorIDs := make([]int64, 1) + var ok bool + + if authorIDs[0], ok = session.Values["id"].(int64); !ok { + msg := "fälschlicherweise session.Values[\"id\"].(int64) für authorIDs[0] angenommen" + log.Println(msg) + http.Error(w, msg, http.StatusInternalServerError) + return + } + + if err = db.WriteArticleAuthors(article.ID, authorIDs); err != nil { + log.Println(err) + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } + content := []byte(r.PostFormValue("issue-content")) if len(content) == 0 { http.Error(w, "Bitte eine Beschreibung eingeben.", http.StatusBadRequest)