@@ -116,55 +116,55 @@ function parseHistoryToObject (history) {
116116function historyGet ( req , res ) {
117117 if ( req . isAuthenticated ( ) ) {
118118 getHistory ( req . user . id , function ( err , history ) {
119- if ( err ) return response . errorInternalError ( res )
120- if ( ! history ) return response . errorNotFound ( res )
119+ if ( err ) return response . errorInternalError ( req , res )
120+ if ( ! history ) return response . errorNotFound ( req , res )
121121 res . send ( {
122122 history : parseHistoryToArray ( history )
123123 } )
124124 } )
125125 } else {
126- return response . errorForbidden ( res )
126+ return response . errorForbidden ( req , res )
127127 }
128128}
129129
130130function historyPost ( req , res ) {
131131 if ( req . isAuthenticated ( ) ) {
132132 var noteId = req . params . noteId
133133 if ( ! noteId ) {
134- if ( typeof req . body [ 'history' ] === 'undefined' ) return response . errorBadRequest ( res )
134+ if ( typeof req . body [ 'history' ] === 'undefined' ) return response . errorBadRequest ( req , res )
135135 if ( config . debug ) { logger . info ( 'SERVER received history from [' + req . user . id + ']: ' + req . body . history ) }
136136 try {
137137 var history = JSON . parse ( req . body . history )
138138 } catch ( err ) {
139- return response . errorBadRequest ( res )
139+ return response . errorBadRequest ( req , res )
140140 }
141141 if ( Array . isArray ( history ) ) {
142142 setHistory ( req . user . id , history , function ( err , count ) {
143- if ( err ) return response . errorInternalError ( res )
143+ if ( err ) return response . errorInternalError ( req , res )
144144 res . end ( )
145145 } )
146146 } else {
147- return response . errorBadRequest ( res )
147+ return response . errorBadRequest ( req , res )
148148 }
149149 } else {
150- if ( typeof req . body [ 'pinned' ] === 'undefined' ) return response . errorBadRequest ( res )
150+ if ( typeof req . body [ 'pinned' ] === 'undefined' ) return response . errorBadRequest ( req , res )
151151 getHistory ( req . user . id , function ( err , history ) {
152- if ( err ) return response . errorInternalError ( res )
153- if ( ! history ) return response . errorNotFound ( res )
154- if ( ! history [ noteId ] ) return response . errorNotFound ( res )
152+ if ( err ) return response . errorInternalError ( req , res )
153+ if ( ! history ) return response . errorNotFound ( req , res )
154+ if ( ! history [ noteId ] ) return response . errorNotFound ( req , res )
155155 if ( req . body . pinned === 'true' || req . body . pinned === 'false' ) {
156156 history [ noteId ] . pinned = ( req . body . pinned === 'true' )
157157 setHistory ( req . user . id , history , function ( err , count ) {
158- if ( err ) return response . errorInternalError ( res )
158+ if ( err ) return response . errorInternalError ( req , res )
159159 res . end ( )
160160 } )
161161 } else {
162- return response . errorBadRequest ( res )
162+ return response . errorBadRequest ( req , res )
163163 }
164164 } )
165165 }
166166 } else {
167- return response . errorForbidden ( res )
167+ return response . errorForbidden ( req , res )
168168 }
169169}
170170
@@ -173,22 +173,22 @@ function historyDelete (req, res) {
173173 var noteId = req . params . noteId
174174 if ( ! noteId ) {
175175 setHistory ( req . user . id , [ ] , function ( err , count ) {
176- if ( err ) return response . errorInternalError ( res )
176+ if ( err ) return response . errorInternalError ( req , res )
177177 res . end ( )
178178 } )
179179 } else {
180180 getHistory ( req . user . id , function ( err , history ) {
181- if ( err ) return response . errorInternalError ( res )
182- if ( ! history ) return response . errorNotFound ( res )
181+ if ( err ) return response . errorInternalError ( req , res )
182+ if ( ! history ) return response . errorNotFound ( req , res )
183183 delete history [ noteId ]
184184 setHistory ( req . user . id , history , function ( err , count ) {
185- if ( err ) return response . errorInternalError ( res )
185+ if ( err ) return response . errorInternalError ( req , res )
186186 res . end ( )
187187 } )
188188 } )
189189 }
190190 } else {
191- return response . errorForbidden ( res )
191+ return response . errorForbidden ( req , res )
192192 }
193193}
194194
0 commit comments