Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Unneeded warning in payload of REST API calls #9240

Merged
merged 1 commit into from
Dec 26, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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