summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/node/db/API.js18
-rw-r--r--src/node/db/Pad.js8
-rw-r--r--src/node/handler/APIHandler.js1
3 files changed, 26 insertions, 1 deletions
diff --git a/src/node/db/API.js b/src/node/db/API.js
index c766c80a..e2b6f6f8 100644
--- a/src/node/db/API.js
+++ b/src/node/db/API.js
@@ -284,6 +284,24 @@ exports.getRevisionsCount = function(padID, callback)
}
/**
+getLastEdited(padID) returns the timestamp of the last revision of the pad
+
+Example returns:
+
+{code: 0, message:"ok", data: {lastEdited: 1340815946602}}
+{code: 1, message:"padID does not exist", data: null}
+*/
+exports.getLastEdited = function(padID, callback)
+{
+ //get the pad
+ getPadSafe(padID, true, function(err, pad)
+ {
+ if(ERR(err, callback)) return;
+ callback(null, {lastEdited: pad.getLastEdited()});
+ });
+}
+
+/**
createPad(padName [, text]) creates a new pad in this group
Example returns:
diff --git a/src/node/db/Pad.js b/src/node/db/Pad.js
index 5e005606..82159676 100644
--- a/src/node/db/Pad.js
+++ b/src/node/db/Pad.js
@@ -80,7 +80,7 @@ Pad.prototype.appendRevision = function appendRevision(aChangeset, author) {
newRevData.meta.atext = this.atext;
}
- db.set("pad:"+this.id+":revs:"+newRev, newRevData);
+ db.set("pad:"+this.id+":revs:"+newRev, newRevData);
this.saveToDatabase();
// set the author to pad
@@ -106,6 +106,12 @@ Pad.prototype.saveToDatabase = function saveToDatabase(){
db.set("pad:"+this.id, dbObject);
}
+// get time of last edit (changeset application)
+Pad.prototype.getLastEdit = function getLastEdit(callback){
+ var revNum = this.getHeadRevisionNumber();
+ db.getSub("pad:"+this.id+":revs:"+revNum, ["meta", "timestamp"], callback);
+}
+
Pad.prototype.getRevisionChangeset = function getRevisionChangeset(revNum, callback) {
db.getSub("pad:"+this.id+":revs:"+revNum, ["changeset"], callback);
};
diff --git a/src/node/handler/APIHandler.js b/src/node/handler/APIHandler.js
index b6bb93bd..567a90d2 100644
--- a/src/node/handler/APIHandler.js
+++ b/src/node/handler/APIHandler.js
@@ -58,6 +58,7 @@ var functions = {
"getHTML" : ["padID", "rev"],
"setHTML" : ["padID", "html"],
"getRevisionsCount" : ["padID"],
+ "getLastEdited" : ["padID"],
"deletePad" : ["padID"],
"getReadOnlyID" : ["padID"],
"setPublicStatus" : ["padID", "publicStatus"],