@@ -204,7 +204,7 @@ exports.clientVars = (hook, context, cb) => {
204204} ;
205205
206206exports . expressCreateServer = ( hookName , args , callback ) => {
207- args . app . get ( '/p/:pad/:rev?/comments' , async ( req , res ) => {
207+ const handlePadRevComments = async ( req , res ) => {
208208 const fields = req . query ;
209209 // check the api key
210210 if ( ! apiUtils . validateApiKey ( fields , res ) ) return ;
@@ -222,9 +222,17 @@ exports.expressCreateServer = (hookName, args, callback) => {
222222 }
223223 if ( data == null ) return ;
224224 res . json ( { code : 0 , data} ) ;
225+ }
226+
227+ args . app . get ( '/p/:pad/:rev/comments' , async ( req , res ) => {
228+ await handlePadRevComments ( req , res )
225229 } ) ;
226230
227- args . app . post ( '/p/:pad/:rev?/comments' , async ( req , res ) => {
231+ args . app . get ( '/p/:pad/comments' , async ( req , res ) => {
232+ await handlePadRevComments ( req , res )
233+ } ) ;
234+
235+ const postRevision = async ( req , res ) => {
228236 const fields = await new Promise ( ( resolve , reject ) => {
229237 new Formidable ( ) . parse ( req , ( err , fields ) => err ? reject ( err ) : resolve ( fields ) ) ;
230238 } ) ;
@@ -260,9 +268,18 @@ exports.expressCreateServer = (hookName, args, callback) => {
260268 io . to ( padIdReceived ) . emit ( 'pushAddComment' , commentIds [ i ] , comments [ i ] ) ;
261269 }
262270 res . json ( { code : 0 , commentIds} ) ;
271+ }
272+
273+ args . app . post ( '/p/:pad/:rev/comments' , async ( req , res ) => {
274+ await postRevision ( req , res ) ;
275+ } ) ;
276+
277+ args . app . post ( '/p/:pad/comments' , async ( req , res ) => {
278+ await postRevision ( req , res ) ;
263279 } ) ;
264280
265- args . app . get ( '/p/:pad/:rev?/commentReplies' , async ( req , res ) => {
281+
282+ const getCommentReplies = async ( req , res ) => {
266283 // it's the same thing as the formidable's fields
267284 const fields = req . query ;
268285 // check the api key
@@ -282,9 +299,17 @@ exports.expressCreateServer = (hookName, args, callback) => {
282299 }
283300 if ( data == null ) return ;
284301 res . json ( { code : 0 , data} ) ;
302+ }
303+
304+ args . app . get ( '/p/:pad/commentReplies' , async ( req , res ) => {
305+ await getCommentReplies ( req , res ) ;
285306 } ) ;
286307
287- args . app . post ( '/p/:pad/:rev?/commentReplies' , async ( req , res ) => {
308+ args . app . get ( '/p/:pad/:rev/commentReplies' , async ( req , res ) => {
309+ await getCommentReplies ( req , res ) ;
310+ } ) ;
311+
312+ const postCommentReplies = async ( req , res ) => {
288313 const fields = await new Promise ( ( resolve , reject ) => {
289314 new Formidable ( ) . parse ( req , ( err , fields ) => err ? reject ( err ) : resolve ( fields ) ) ;
290315 } ) ;
@@ -321,6 +346,15 @@ exports.expressCreateServer = (hookName, args, callback) => {
321346 io . to ( padIdReceived ) . emit ( 'pushAddCommentReply' , replyIds [ i ] , replies [ i ] ) ;
322347 }
323348 res . json ( { code : 0 , replyIds} ) ;
349+ }
350+
351+ args . app . post ( '/p/:pad/:rev/commentReplies' , async ( req , res ) => {
352+ await postCommentReplies ( req , res ) ;
353+ } ) ;
354+
355+ args . app . post ( '/p/:pad/commentReplies' , async ( req , res ) => {
356+ await postCommentReplies ( req , res ) ;
324357 } ) ;
358+
325359 return callback ( ) ;
326360} ;
0 commit comments