@@ -14,6 +14,7 @@ var config = require('./config')
14
14
var logger = require ( './logger' )
15
15
var models = require ( './models' )
16
16
var utils = require ( './utils' )
17
+ var history = require ( './history' )
17
18
18
19
// public
19
20
var response = {
@@ -106,6 +107,12 @@ function responseCodiMD (res, note) {
106
107
} )
107
108
}
108
109
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
+
109
116
function newNote ( req , res , next ) {
110
117
var owner = null
111
118
var body = ''
@@ -125,6 +132,11 @@ function newNote (req, res, next) {
125
132
alias : req . alias ? req . alias : null ,
126
133
content : body
127
134
} ) . then ( function ( note ) {
135
+
136
+ if ( req . isAuthenticated ( ) ) {
137
+ updateHistory ( owner , note , body ) ;
138
+ }
139
+
128
140
return res . redirect ( config . serverURL + '/' + models . Note . encodeNoteId ( note . id ) )
129
141
} ) . catch ( function ( err ) {
130
142
logger . error ( err )
0 commit comments