Save note title to database when creating a note

Currently, when creating a note with content via the API, a title is only saved to the database after visiting the note with the browser. This commit makes sure that a title is saved at creation time.

Closes #306

Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
David Mehren 2020-11-11 21:24:55 +01:00
parent e28bc8eab4
commit 9dd74da17f
No known key found for this signature in database
GPG key ID: 185982BA4C42B7C3

View file

@ -59,7 +59,8 @@ exports.newNote = function (req, res, body) {
models.Note.create({
ownerId: owner,
alias: req.alias ? req.alias : null,
content: body
content: body,
title: models.Note.parseNoteTitle(body)
}).then(function (note) {
return res.redirect(config.serverURL + '/' + (note.alias ? note.alias : models.Note.encodeNoteId(note.id)))
}).catch(function (err) {