Check if content exists before adding article to DB
This commit is contained in:
parent
973abc8a81
commit
7da98fb2ab
@ -155,13 +155,6 @@ func SubmitArticle(c *b.Config, db *b.DB, s map[string]*Session) http.HandlerFun
|
||||
return
|
||||
}
|
||||
|
||||
article.ID, err = db.AddArticle(article)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
content := []byte(r.PostFormValue("article-content"))
|
||||
if len(content) == 0 {
|
||||
http.Error(w, "Bitte den Artikel eingeben.", http.StatusBadRequest)
|
||||
@ -173,6 +166,13 @@ func SubmitArticle(c *b.Config, db *b.DB, s map[string]*Session) http.HandlerFun
|
||||
return
|
||||
}
|
||||
|
||||
article.ID, err = db.AddArticle(article)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
if err = db.WriteArticleAuthors(article.ID, authors); err != nil {
|
||||
log.Println(err)
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
|
Loading…
x
Reference in New Issue
Block a user