Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 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
13 changes: 12 additions & 1 deletion app/api/server/v1/channels.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Meteor } from 'meteor/meteor';
import { Match, check } from 'meteor/check';
import _ from 'underscore';

import { Rooms, Subscriptions, Messages, Uploads, Integrations, Users } from '../../../models';
Expand Down Expand Up @@ -577,6 +578,11 @@ API.v1.addRoute('channels.members', { authRequired: true }, {

const { offset, count } = this.getPaginationItems();
const { sort = {} } = this.parseJsonQuery();
const { status, username, name } = this.queryParams;

check(status, Match.Maybe([String]));
check(username, Match.Maybe(String));
check(name, Match.Maybe(String));

const subscriptions = Subscriptions.findByRoomId(findResult._id, {
fields: { 'u._id': 1 },
Comment thread
sampaiodiego marked this conversation as resolved.
Outdated
Expand All @@ -588,8 +594,13 @@ API.v1.addRoute('channels.members', { authRequired: true }, {
const total = subscriptions.count();

const members = subscriptions.fetch().map((s) => s.u && s.u._id);
const query = {
name,
Comment thread
KevLehman marked this conversation as resolved.
Outdated
username,
status: status ? { $in: status } : undefined,
};

const users = Users.find({ _id: { $in: members } }, {
const users = Users.find({ ...query, _id: { $in: members } }, {
fields: { _id: 1, username: 1, name: 1, status: 1, statusText: 1, utcOffset: 1 },
sort: { username: sort.username != null ? sort.username : 1 },
}).fetch();
Expand Down
14 changes: 12 additions & 2 deletions app/api/server/v1/groups.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import _ from 'underscore';
import { Meteor } from 'meteor/meteor';
import { Match } from 'meteor/check';
import { Match, check } from 'meteor/check';

import { mountIntegrationQueryBasedOnPermissions } from '../../../integrations/server/lib/mountQueriesBasedOnPermission';
import { Subscriptions, Rooms, Messages, Uploads, Integrations, Users } from '../../../models/server';
Expand Down Expand Up @@ -500,6 +500,11 @@ API.v1.addRoute('groups.members', { authRequired: true }, {

const { offset, count } = this.getPaginationItems();
const { sort = {} } = this.parseJsonQuery();
const { status, username, name } = this.queryParams;
Comment thread
KevLehman marked this conversation as resolved.
Outdated

check(status, Match.Maybe([String]));
check(username, Match.Maybe(String));
check(name, Match.Maybe(String));

const subscriptions = Subscriptions.findByRoomId(findResult.rid, {
fields: { 'u._id': 1 },
Expand All @@ -511,8 +516,13 @@ API.v1.addRoute('groups.members', { authRequired: true }, {
const total = subscriptions.count();

const members = subscriptions.fetch().map((s) => s.u && s.u._id);
const query = {
name,
username,
status: status ? { $in: status } : undefined,
};

const users = Users.find({ _id: { $in: members } }, {
const users = Users.find({ ...query, _id: { $in: members } }, {
fields: { _id: 1, username: 1, name: 1, status: 1, statusText: 1, utcOffset: 1 },
sort: { username: sort.username != null ? sort.username : 1 },
}).fetch();
Expand Down