Skip to content

Commit

Permalink
Merge pull request #9240 from RocketChat/hotfix/9037
Browse files Browse the repository at this point in the history
Fix: Unneeded warning in payload of REST API calls
  • Loading branch information
rodrigok committed Dec 26, 2017
1 parent 3848d20 commit 35aaf64
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions packages/rocketchat-api/server/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ class API extends Restivus {
success(result = {}) {
if (_.isObject(result)) {
result.success = true;
// TODO: Remove this after three versions have been released. That means at 0.64 this should be gone. ;)
result.developerWarning = '[WARNING]: The "usernames" field has been removed for performance reasons. Please use the "*.members" endpoint to get a list of members/users in a room.';
}

return {
Expand Down Expand Up @@ -141,7 +139,20 @@ class API extends Restivus {
return RocketChat.API.v1.failure(e.message, e.error);
}

return result ? result : RocketChat.API.v1.success();
result = result ? result : RocketChat.API.v1.success();

if (
/(channels|groups)\./.test(route)
&& result
&& result.body
&& result.body.success === true
&& (result.body.channel || result.body.channels || result.body.group || result.body.groups)
) {
// TODO: Remove this after three versions have been released. That means at 0.64 this should be gone. ;)
result.body.developerWarning = '[WARNING]: The "usernames" field has been removed for performance reasons. Please use the "*.members" endpoint to get a list of members/users in a room.';
}

return result;
};

for (const [name, helperMethod] of this.helperMethods) {
Expand Down

0 comments on commit 35aaf64

Please sign in to comment.