Skip to content

Commit 43c0bff

Browse files
authored
Merge pull request #1179 from cdancette/update-history-on-creation
Update history on note creation
2 parents 602548c + c078d2d commit 43c0bff

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

lib/response.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ var config = require('./config')
1414
var logger = require('./logger')
1515
var models = require('./models')
1616
var utils = require('./utils')
17+
var history = require('./history')
1718

1819
// public
1920
var response = {
@@ -106,6 +107,12 @@ function responseCodiMD (res, note) {
106107
})
107108
}
108109

110+
function updateHistory (userId, note, document, time) {
111+
var noteId = note.alias ? note.alias : models.Note.encodeNoteId(note.id)
112+
history.updateHistory(userId, noteId, document, time)
113+
logger.info("history updated")
114+
}
115+
109116
function newNote (req, res, next) {
110117
var owner = null
111118
var body = ''
@@ -125,6 +132,11 @@ function newNote (req, res, next) {
125132
alias: req.alias ? req.alias : null,
126133
content: body
127134
}).then(function (note) {
135+
136+
if (req.isAuthenticated()) {
137+
updateHistory(owner, note, body);
138+
}
139+
128140
return res.redirect(config.serverURL + '/' + models.Note.encodeNoteId(note.id))
129141
}).catch(function (err) {
130142
logger.error(err)

0 commit comments

Comments
 (0)