@@ -14,6 +14,7 @@ var config = require('./config')
1414var logger = require ( './logger' )
1515var models = require ( './models' )
1616var utils = require ( './utils' )
17+ var history = require ( './history' )
1718
1819// public
1920var 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+
109116function 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