mirror of https://github.com/status-im/codimd.git
Merge pull request #1179 from cdancette/update-history-on-creation
Update history on note creation
This commit is contained in:
commit
43c0bff8c4
|
@ -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