mirror of https://github.com/status-im/codimd.git
Update history on note creation
Signed-off-by: Corentin <corentin@cdancette.fr>
This commit is contained in:
parent
50c80c99a4
commit
c078d2d304
|
@ -14,6 +14,7 @@ var config = require('./config')
|
||||||
var logger = require('./logger')
|
var logger = require('./logger')
|
||||||
var models = require('./models')
|
var models = require('./models')
|
||||||
var utils = require('./utils')
|
var utils = require('./utils')
|
||||||
|
var history = require('./history')
|
||||||
|
|
||||||
// public
|
// public
|
||||||
var response = {
|
var response = {
|
||||||
|
@ -106,6 +107,12 @@ function responseCodiMD (res, note) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function updateHistory (userId, note, document, time) {
|
||||||
|
var noteId = note.alias ? note.alias : models.Note.encodeNoteId(note.id)
|
||||||
|
history.updateHistory(userId, noteId, document, time)
|
||||||
|
logger.info("history updated")
|
||||||
|
}
|
||||||
|
|
||||||
function newNote (req, res, next) {
|
function newNote (req, res, next) {
|
||||||
var owner = null
|
var owner = null
|
||||||
var body = ''
|
var body = ''
|
||||||
|
@ -125,6 +132,11 @@ function newNote (req, res, next) {
|
||||||
alias: req.alias ? req.alias : null,
|
alias: req.alias ? req.alias : null,
|
||||||
content: body
|
content: body
|
||||||
}).then(function (note) {
|
}).then(function (note) {
|
||||||
|
|
||||||
|
if (req.isAuthenticated()) {
|
||||||
|
updateHistory(owner, note, body);
|
||||||
|
}
|
||||||
|
|
||||||
return res.redirect(config.serverURL + '/' + models.Note.encodeNoteId(note.id))
|
return res.redirect(config.serverURL + '/' + models.Note.encodeNoteId(note.id))
|
||||||
}).catch(function (err) {
|
}).catch(function (err) {
|
||||||
logger.error(err)
|
logger.error(err)
|
||||||
|
|
Loading…
Reference in New Issue