mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-01-20 06:29:53 +01:00
Add in getLastEdited API call
This new HTTP API call, getLastEdited, will return the time of the last revision, in UNIX timestamp format.
This commit is contained in:
parent
0bc01feb72
commit
ab0d3c87cb
3 changed files with 26 additions and 1 deletions
|
@ -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
|
createPad(padName [, text]) creates a new pad in this group
|
||||||
|
|
||||||
|
|
|
@ -102,6 +102,12 @@ Pad.prototype.saveToDatabase = function saveToDatabase(){
|
||||||
db.set("pad:"+this.id, dbObject);
|
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) {
|
Pad.prototype.getRevisionChangeset = function getRevisionChangeset(revNum, callback) {
|
||||||
db.getSub("pad:"+this.id+":revs:"+revNum, ["changeset"], callback);
|
db.getSub("pad:"+this.id+":revs:"+revNum, ["changeset"], callback);
|
||||||
};
|
};
|
||||||
|
|
|
@ -57,6 +57,7 @@ var functions = {
|
||||||
"getHTML" : ["padID", "rev"],
|
"getHTML" : ["padID", "rev"],
|
||||||
"setHTML" : ["padID", "html"],
|
"setHTML" : ["padID", "html"],
|
||||||
"getRevisionsCount" : ["padID"],
|
"getRevisionsCount" : ["padID"],
|
||||||
|
"getLastEdited" : ["padID"],
|
||||||
"deletePad" : ["padID"],
|
"deletePad" : ["padID"],
|
||||||
"getReadOnlyID" : ["padID"],
|
"getReadOnlyID" : ["padID"],
|
||||||
"setPublicStatus" : ["padID", "publicStatus"],
|
"setPublicStatus" : ["padID", "publicStatus"],
|
||||||
|
|
Loading…
Reference in a new issue