Skip to content

Commit

Permalink
Prevent moderation configuration options from resetting to defaults w…
Browse files Browse the repository at this point in the history
…hen updating an application.
  • Loading branch information
Allen Weiss committed Mar 18, 2015
1 parent eb6df8c commit cd20ff1
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
30 changes: 24 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -331,12 +331,20 @@ CleanSpeak.prototype.deleteApplication = function(id, opts, callback) {
};

/*
* Updates an existing application. Currently only supports name change.
* Updates an existing application.
*
* @param {uuid} id ID for the application
* @param {string} opts.name Name for the application
* @param {callback} function Callback when complete (err, result)
* @returns {string} err Error message if error occurs
* @param {uuid} id ID for the application
* @param {string} opts.name Name for the application
* @param {bool} opts.storeContent true if all content should be stored in CleanSpeak's database.
* @param {bool} opts.persistent true if content should be persistent (eligible for moderation).
* Defaults to false (transient).
* @param {bool} opts.contentEditable true if the content in the application can be edited by moderators.
* @param {bool} opts.contentDeletable true if the content in the application can be delete by moderators.
* @param {bool} opts.defaultActionIsQueueForApproval true if all content should be queued (pre-moderation).
* If false, this can still be set on individual moderation calls.
* @param {bool} opts.contentUserActionsEnabled true if users in this application can be actioned by moderators.
* @param {callback} function Callback when complete (err, result)
* @returns {string} err Error message if error occurs
*
*/
CleanSpeak.prototype.updateApplication = function(id, opts, callback) {
Expand All @@ -351,9 +359,19 @@ CleanSpeak.prototype.updateApplication = function(id, opts, callback) {
Authentication: this.authToken,
'Content-Type': 'application/json'
};

var moderationOpts = _.pick(opts, [
'contentDeletable',
'contentEditable',
'contentUserActionsEnabled',
'defaultActionIsQueueForApproval',
'persistent',
'storeContent'
]);
var body = {
application: {
name: opts.name
name: opts.name,
moderationConfiguration: moderationOpts
}
};

Expand Down
3 changes: 2 additions & 1 deletion test/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,8 @@ describe('CleanSpeak', function() {
mockRequest = nock('http://cleanspeak.example.com:8001')
.put('/system/application/' + id, {
application: {
name: name
name: name,
moderationConfiguration: {}
}
})
.reply(200, {});
Expand Down

0 comments on commit cd20ff1

Please sign in to comment.