diff --git a/node/db/API.js b/node/db/API.js index 28dabb13..6bfc4f42 100644 --- a/node/db/API.js +++ b/node/db/API.js @@ -360,13 +360,17 @@ Example returns: */ exports.getRevisionsCount = function(padID, callback) { - //check if this is a valid padID - var notValidReason = isValidPadID(padID); - if(notValidReason != null) + //get the pad + getPadSafe(padID, function(err, pad) { - callback(notValidReason); - return; - } + if(err) + { + callback(err); + return; + } + + callback(null, {revisions: pad.getHeadRevisionNumber()}); + }); } /** @@ -379,13 +383,17 @@ Example returns: */ exports.deletePad = function(padID, callback) { - //check if this is a valid padID - var notValidReason = isValidPadID(padID); - if(notValidReason != null) + //get the pad + getPadSafe(padID, function(err, pad) { - callback(notValidReason); - return; - } + if(err) + { + callback(err); + return; + } + + + }); } /** @@ -398,13 +406,7 @@ Example returns: */ exports.getReadOnlyLink = function(padID, callback) { - //check if this is a valid padID - var notValidReason = isValidPadID(padID); - if(notValidReason != null) - { - callback(notValidReason); - return; - } + } /** @@ -417,13 +419,17 @@ Example returns: */ exports.setPublicStatus = function(padID, publicStatus, callback) { - //check if this is a valid padID - var notValidReason = isValidPadID(padID); - if(notValidReason != null) + //get the pad + getPadSafe(padID, function(err, pad) { - callback(notValidReason); - return; - } + if(err) + { + callback(err); + return; + } + + + }); } /** @@ -436,13 +442,17 @@ Example returns: */ exports.getPublicStatus = function(padID, callback) { - //check if this is a valid padID - var notValidReason = isValidPadID(padID); - if(notValidReason != null) + //get the pad + getPadSafe(padID, function(err, pad) { - callback(notValidReason); - return; - } + if(err) + { + callback(err); + return; + } + + + }); } /** @@ -455,13 +465,17 @@ Example returns: */ exports.setPassword = function(padID, password, callback) { - //check if this is a valid padID - var notValidReason = isValidPadID(padID); - if(notValidReason != null) + //get the pad + getPadSafe(padID, function(err, pad) { - callback(notValidReason); - return; - } + if(err) + { + callback(err); + return; + } + + + }); } /** @@ -474,13 +488,17 @@ Example returns: */ exports.isPasswordProtected = function(padID, callback) { - //check if this is a valid padID - var notValidReason = isValidPadID(padID); - if(notValidReason != null) + //get the pad + getPadSafe(padID, function(err, pad) { - callback(notValidReason); - return; - } + if(err) + { + callback(err); + return; + } + + + }); } /******************************/ diff --git a/node/handler/APIHandler.js b/node/handler/APIHandler.js index 20d4d30f..8cb9e9c8 100644 --- a/node/handler/APIHandler.js +++ b/node/handler/APIHandler.js @@ -50,8 +50,8 @@ var functions = { // "deleteAllSessionsOfGroup" : ["groupID"], // "deleteAllSessionsOfAuthor" : ["authorID"], "getText" : ["padID", "rev"], - "setText" : ["padID", "text"] -// "getRevisionsCount" : ["padID"], + "setText" : ["padID", "text"], + "getRevisionsCount" : ["padID"], // "deletePad" : ["padID"], // "getReadOnlyLink" : ["padID"], // "setPublicStatus" : ["padID", "publicStatus"],