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

Regression: Add support to filter on teams.listRooms endpoint #21327

Merged
merged 2 commits into from
Mar 29, 2021

Conversation

matheusbsilva137
Copy link
Member

Proposed changes (including videos or screenshots)

  • Add support for queries (within the query parameter);
  • Add support to pagination (offset and count) when an user doesn't have the permission to get all rooms.

Issue(s)

Task - ClickUp

Steps to test or reproduce

Example input (using cURL):

curl -G 'http://localhost:3000/api/v1/teams.listRooms?teamId=60538ebf22ff2e119e52f086' \
  --data-urlencode 'query={"ts":{"$gt":{"$date":"2021-03-26T19:46:38.143Z"}}}' \
  -H 'X-Auth-Token: c3rQDH_Fpa7JHSgUrWvlpxwIi1AAu4qTnfAF4SFgWkB' \
  -H 'X-User-Id: dizcH9Edm8hC7ziDX' \
  -H 'Content-Type: application/json'

Further comments

@@ -396,13 +396,13 @@ export class TeamService extends ServiceClass implements ITeamService {
throw new Error('user-not-on-private-team');
}
if (getAllRooms) {
const teamRoomsCursor = this.RoomsModel.findByTeamId(teamId, { skip, limit });
const teamRoomsCursor = this.RoomsModel.findByTeamId(teamId, { skip, limit }, query as FilterQuery<IRoom>);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to type cast as FilterQuery =) typescript can already infer that from the param ;)

Suggested change
const teamRoomsCursor = this.RoomsModel.findByTeamId(teamId, { skip, limit }, query as FilterQuery<IRoom>);
const teamRoomsCursor = this.RoomsModel.findByTeamId(teamId, { skip, limit }, query);

return {
total: await teamRoomsCursor.count(),
records: await teamRoomsCursor.toArray(),
};
}
const teamRooms = await this.RoomsModel.findByTeamId(teamId, { projection: { _id: 1, t: 1 } }).toArray();
const teamRooms = await this.RoomsModel.findByTeamId(teamId, { skip, limit, projection: { _id: 1, t: 1 } }, query as FilterQuery<IRoom>).toArray();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const teamRooms = await this.RoomsModel.findByTeamId(teamId, { skip, limit, projection: { _id: 1, t: 1 } }, query as FilterQuery<IRoom>).toArray();
const teamRooms = await this.RoomsModel.findByTeamId(teamId, { skip, limit, projection: { _id: 1, t: 1 } }, query).toArray();

app/models/server/raw/Rooms.js Show resolved Hide resolved
@sampaiodiego sampaiodiego changed the title [IMPROVE] teams.listRooms endpoint doesn't support queries Regression: Add support to filter on teams.listRooms endpoint Mar 29, 2021
@sampaiodiego sampaiodiego merged commit b10da0b into develop Mar 29, 2021
@sampaiodiego sampaiodiego deleted the teams-back-list-rooms-queries branch March 29, 2021 17:48
@sampaiodiego sampaiodiego mentioned this pull request Apr 3, 2021
13 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants