Fix regression in api channels.members

pull/9110/head
Rodrigo Nascimento 8 years ago
parent 6f4f154983
commit 4834deff0d
No known key found for this signature in database
GPG Key ID: CFCE33B7B01AC335
  1. 13
      packages/rocketchat-api/server/v1/channels.js

@ -1,16 +1,21 @@
import _ from 'underscore';
//Returns the channel IF found otherwise it will return the failure of why it didn't. Check the `statusCode` property
function findChannelByIdOrName({ params, checkedArchived = true }) {
function findChannelByIdOrName({ params, checkedArchived = true, returnUsernames = false }) {
if ((!params.roomId || !params.roomId.trim()) && (!params.roomName || !params.roomName.trim())) {
throw new Meteor.Error('error-roomid-param-not-provided', 'The parameter "roomId" or "roomName" is required');
}
const fields = { ...RocketChat.API.v1.defaultFieldsToExclude };
if (returnUsernames) {
delete fields.usernames;
}
let room;
if (params.roomId) {
room = RocketChat.models.Rooms.findOneById(params.roomId, { fields: RocketChat.API.v1.defaultFieldsToExclude });
room = RocketChat.models.Rooms.findOneById(params.roomId, { fields });
} else if (params.roomName) {
room = RocketChat.models.Rooms.findOneByName(params.roomName, { fields: RocketChat.API.v1.defaultFieldsToExclude });
room = RocketChat.models.Rooms.findOneByName(params.roomName, { fields });
}
if (!room || room.t !== 'c') {
@ -421,7 +426,7 @@ RocketChat.API.v1.addRoute('channels.list.joined', { authRequired: true }, {
RocketChat.API.v1.addRoute('channels.members', { authRequired: true }, {
get() {
const findResult = findChannelByIdOrName({ params: this.requestParams(), checkedArchived: false });
const findResult = findChannelByIdOrName({ params: this.requestParams(), checkedArchived: false, returnUsernames: true });
const { offset, count } = this.getPaginationItems();
const { sort } = this.parseJsonQuery();

Loading…
Cancel
Save