Add in getLastEdited API call

This new HTTP API call, getLastEdited, will return the time of the
last revision, in UNIX timestamp format.
pull/820/head
Mark Holmquist 2012-06-27 09:55:03 -07:00
parent 0bc01feb72
commit ab0d3c87cb
3 changed files with 26 additions and 1 deletions

View File

@ -282,6 +282,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

View File

@ -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();
};
@ -102,6 +102,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);
};

View File

@ -57,6 +57,7 @@ var functions = {
"getHTML" : ["padID", "rev"],
"setHTML" : ["padID", "html"],
"getRevisionsCount" : ["padID"],
"getLastEdited" : ["padID"],
"deletePad" : ["padID"],
"getReadOnlyID" : ["padID"],
"setPublicStatus" : ["padID", "publicStatus"],