From 493636ec3661b2ad96bc16a7943d9b69aad9695c Mon Sep 17 00:00:00 2001 From: Stephan Jauernick Date: Sat, 31 May 2014 00:39:36 +0200 Subject: [PATCH 1/5] Added a new API method getPadID for reversing the Readonly ID and introduced the API level 1.4.1. Based on: https://github.com/disy-mk/etherpad-lite/commit/97402f60b89549b32238505397c781dce8d79a4c --- src/node/handler/APIHandler.js | 47 +++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/src/node/handler/APIHandler.js b/src/node/handler/APIHandler.js index 62025c50..2fb07a60 100644 --- a/src/node/handler/APIHandler.js +++ b/src/node/handler/APIHandler.js @@ -300,10 +300,55 @@ var version = , "getChatHistory" : ["padID", "start", "end"] , "getChatHead" : ["padID"] } +, "1.4.1": + { "createGroup" : [] + , "createGroupIfNotExistsFor" : ["groupMapper"] + , "deleteGroup" : ["groupID"] + , "listPads" : ["groupID"] + , "listAllPads" : [] + , "createDiffHTML" : ["padID", "startRev", "endRev"] + , "createPad" : ["padID", "text"] + , "createGroupPad" : ["groupID", "padName", "text"] + , "createAuthor" : ["name"] + , "createAuthorIfNotExistsFor": ["authorMapper" , "name"] + , "listPadsOfAuthor" : ["authorID"] + , "createSession" : ["groupID", "authorID", "validUntil"] + , "deleteSession" : ["sessionID"] + , "getSessionInfo" : ["sessionID"] + , "listSessionsOfGroup" : ["groupID"] + , "listSessionsOfAuthor" : ["authorID"] + , "getText" : ["padID", "rev"] + , "setText" : ["padID", "text"] + , "getHTML" : ["padID", "rev"] + , "setHTML" : ["padID", "html"] + , "getAttributePool" : ["padID"] + , "getRevisionsCount" : ["padID"] + , "getRevisionChangeset" : ["padID", "rev"] + , "getLastEdited" : ["padID"] + , "deletePad" : ["padID"] + , "copyPad" : ["sourceID", "destinationID", "force"] + , "movePad" : ["sourceID", "destinationID", "force"] + , "getReadOnlyID" : ["padID"] + , "getPadID" : ["roID"] + , "setPublicStatus" : ["padID", "publicStatus"] + , "getPublicStatus" : ["padID"] + , "setPassword" : ["padID", "password"] + , "isPasswordProtected" : ["padID"] + , "listAuthorsOfPad" : ["padID"] + , "padUsersCount" : ["padID"] + , "getAuthorName" : ["authorID"] + , "padUsers" : ["padID"] + , "sendClientsMessage" : ["padID", "msg"] + , "listAllGroups" : [] + , "checkToken" : [] + , "getChatHistory" : ["padID"] + , "getChatHistory" : ["padID", "start", "end"] + , "getChatHead" : ["padID"] + } }; // set the latest available API version here -exports.latestApiVersion = '1.2.9'; +exports.latestApiVersion = '1.4.1'; // exports the versions so it can be used by the new Swagger endpoint exports.version = version; From fffdde0c593106f9d5c383e6103fc68b48e3c75d Mon Sep 17 00:00:00 2001 From: Stephan Jauernick Date: Sat, 31 May 2014 00:43:31 +0200 Subject: [PATCH 2/5] Implemented the the new API method getPadID for reversing the Readonly ID. Based on: https://github.com/disy-mk/etherpad-lite/commit/ff88c19fc12887a49fdb752adb15ee3145f521f0 --- src/node/db/API.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/node/db/API.js b/src/node/db/API.js index c1050464..f9e4695d 100644 --- a/src/node/db/API.js +++ b/src/node/db/API.js @@ -640,6 +640,32 @@ exports.getReadOnlyID = function(padID, callback) }); } +/** +getPadID(roID) returns the padID of a pad based on the readonlyID(roID) + +Example returns: + +{code: 0, message:"ok", data: null} +{code: 1, message:"padID does not exist", data: null} +*/ +exports.getPadID = function(roID, callback) +{ + //get the PadId + readOnlyManager.getPadId(roID, function(err, padID) + { + if(ERR(err, callback)) return; + + if(padID == null) + { + callback(new customError("padID does not exist","apierror")); + } + else + { + callback(null, {PadID: padID}); + } + }); +} + /** setPublicStatus(padID, publicStatus) sets a boolean for the public status of a pad From d42a9eb3a62ce1a5cfcd68431162c7b7ea69cd9f Mon Sep 17 00:00:00 2001 From: Stephan Jauernick Date: Sat, 31 May 2014 11:53:44 +0200 Subject: [PATCH 3/5] Enhanced the Example for the API Method getPadID and make the return value consistent to other functions --- src/node/db/API.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/node/db/API.js b/src/node/db/API.js index f9e4695d..a57b8673 100644 --- a/src/node/db/API.js +++ b/src/node/db/API.js @@ -645,7 +645,7 @@ getPadID(roID) returns the padID of a pad based on the readonlyID(roID) Example returns: -{code: 0, message:"ok", data: null} +{code: 0, message:"ok", data: {padID: padID}} {code: 1, message:"padID does not exist", data: null} */ exports.getPadID = function(roID, callback) @@ -661,7 +661,7 @@ exports.getPadID = function(roID, callback) } else { - callback(null, {PadID: padID}); + callback(null, {padID: padID}); } }); } From 412bdd185756d90b3c3da8d4d465f618b397bbc2 Mon Sep 17 00:00:00 2001 From: Stephan Jauernick Date: Sun, 1 Jun 2014 21:19:15 +0200 Subject: [PATCH 4/5] Renamed the variable to prevent possible problems. --- src/node/db/API.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/node/db/API.js b/src/node/db/API.js index a57b8673..4a912368 100644 --- a/src/node/db/API.js +++ b/src/node/db/API.js @@ -651,17 +651,17 @@ Example returns: exports.getPadID = function(roID, callback) { //get the PadId - readOnlyManager.getPadId(roID, function(err, padID) + readOnlyManager.getPadId(roID, function(err, retrievedPadID) { if(ERR(err, callback)) return; - if(padID == null) + if(retrievedPadID == null) { callback(new customError("padID does not exist","apierror")); } else { - callback(null, {padID: padID}); + callback(null, {padID: retrievedPadID}); } }); } From fc3ce3429e552db793dee8ec41159920d3c7df55 Mon Sep 17 00:00:00 2001 From: Stephan Jauernick Date: Sun, 1 Jun 2014 21:21:08 +0200 Subject: [PATCH 5/5] Corrected the API Version number. --- src/node/handler/APIHandler.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/node/handler/APIHandler.js b/src/node/handler/APIHandler.js index 2fb07a60..273a58a6 100644 --- a/src/node/handler/APIHandler.js +++ b/src/node/handler/APIHandler.js @@ -300,7 +300,7 @@ var version = , "getChatHistory" : ["padID", "start", "end"] , "getChatHead" : ["padID"] } -, "1.4.1": +, "1.2.10": { "createGroup" : [] , "createGroupIfNotExistsFor" : ["groupMapper"] , "deleteGroup" : ["groupID"] @@ -348,7 +348,7 @@ var version = }; // set the latest available API version here -exports.latestApiVersion = '1.4.1'; +exports.latestApiVersion = '1.2.10'; // exports the versions so it can be used by the new Swagger endpoint exports.version = version;