Add slug to drafts because uploading media needs slug

This commit is contained in:
Alborz Jafari 2023-08-30 22:07:35 +03:00
parent 7b537e3d4e
commit 6fbb51eb63
2 changed files with 8 additions and 1 deletions

View File

@ -627,7 +627,12 @@ func (db *datastore) CreatePost(userID, collID int64, post *SubmittedPost) (*Pos
ownerCollID := sql.NullInt64{
Valid: false,
}
slug := sql.NullString{"", false}
slugString := *post.Slug
slugValid := true
if slugString == "" {
slugValid = false
}
slug := sql.NullString{slugString, slugValid}
// If an alias was supplied, we'll add this to the collection as well.
if userID > 0 {

View File

@ -635,6 +635,8 @@ func newPost(app *App, w http.ResponseWriter, r *http.Request) error {
}
collID = coll.ID
}
slug := getSlugFromPost(*p.Title, *p.Content, p.Language.String)
p.Slug = &slug
// TODO: return PublicPost from createPost
newPost.Post, err = app.db.CreatePost(userID, collID, p)
}