added updating of messages

This commit is contained in:
hydrabolt
2015-08-15 22:34:09 +01:00
parent 44a9844e0c
commit 5685c5f4ce
5 changed files with 208 additions and 4 deletions

View File

@@ -133,6 +133,21 @@ Internal.XHR.deleteMessage = function( token, channelID, messageID, callback ) {
} );
}
Internal.XHR.updateMessage = function( token, channelID, messageID, messageParameters, callback ){
request
.patch(Endpoints.CHANNELS + "/" + channelID + "/messages/" + messageID)
.set( "authorization", token )
.send( messageParameters )
.end(function(err, res){
if ( err ) {
callback( err );
} else {
callback( null, res.body );
}
});
}
Internal.XHR.getChannelLogs = function( token, channelID, amount, callback ) {
request
.get( Endpoints.CHANNELS + "/" + channelID + "/messages?limit=" + amount )

View File

@@ -34,6 +34,22 @@ exports.List.prototype.length = function() {
return this.contents.length;
}
exports.List.prototype.getIndex = function( object ){
var index = false;
for(elementIndex in this.contents){
var element = this.contents[elementIndex];
if( element[this.discriminator] == object[this.discriminator] ){
return elementIndex;
}
}
return index;
}
exports.List.prototype.removeIndex = function( index ) {
this.contents.splice( index, 1 );
}
@@ -50,6 +66,20 @@ exports.List.prototype.removeElement = function( child ) {
return false;
}
exports.List.prototype.updateElement = function( child, newChild ){
for ( _element in this.contents ) {
var element = this.contents[_element];
if ( child[ this.discriminator ] == element[ this.discriminator ] ) {
this.contents[_element] = newChild;
return true;
}
}
return false;
}
exports.List.prototype.concatSublists = function( whereList, discriminator ) {
//this is meant to look at the contents, and assuming the contents are all lists, concatenate their values.