Skip to content

[FIX] Replace query param by name, username and status on the teams.members endpoint#21539

Merged
sampaiodiego merged 18 commits intodevelopfrom
query-teams-members
May 21, 2021
Merged

[FIX] Replace query param by name, username and status on the teams.members endpoint#21539
sampaiodiego merged 18 commits intodevelopfrom
query-teams-members

Conversation

@matheusbsilva137
Copy link
Contributor

Proposed changes (including videos or screenshots)

  • Replace query param by name, username and status on the teams.members endpoint.

Issue(s)

Task - ClickUp

Steps to test or reproduce

Example input (using cURL):

curl -G 'http://localhost:3000/api/v1/teams.members?teamId=60707a8394cc7506feb463c7&username=some.user&status[]=online' \
  -H 'X-Auth-Token: Dommgtm9xJefbcn7vyjVi2PbrM_Tk3SAnYl043qkflp' \
  -H 'X-User-Id: dizcH9Edm8hC7ziDX' \
  -H 'Content-Type: application/json'

Further comments

const canSeeAllMembers = hasPermission(this.userId, 'view-all-teams', team.roomId);

const query = {
username,
Copy link
Member

Choose a reason for hiding this comment

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

Is it expected that username/name are not RegExp here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, so I should use check to assure this. Right?

Copy link
Member

Choose a reason for hiding this comment

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

I don't think so 🤔 I was thinking that most username/name filters support regexes for searching, but if that's not needed here, then it's fine

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure, but I think that supporting regexes would require some extra work (such as in the getUsersOfRoom method). @sampaiodiego , should this endpoint support RegExp?

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

oops, sry, I forgot to answer the last mention..

so I think the main idea is to be able to use those *.members endpoints wherever getUsersOfRooms is being currently used:

async getUsersOfRoom(rid, showAll, { limit, skip } = {}, filter) {

in that sense it should accept a regex as well..

Copy link
Member

Choose a reason for hiding this comment

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

In that sense, i guess the im.members PR (#21471) should be updated too to support a regex 🤔

const canSeeAllMembers = hasPermission(this.userId, 'view-all-teams', team.roomId);

const query = {
username,
Copy link
Member

Choose a reason for hiding this comment

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

I don't think so 🤔 I was thinking that most username/name filters support regexes for searching, but if that's not needed here, then it's fine

@matheusbsilva137 matheusbsilva137 requested a review from KevLehman May 3, 2021 18:49
KevLehman
KevLehman previously approved these changes May 4, 2021
username: username ? new RegExp(username, 'i') : undefined,
name: name ? new RegExp(name, 'i') : undefined,
status: status ? { $in: status } : undefined,
} as Partial<FindOneOptions<IUser>>;
Copy link
Member

Choose a reason for hiding this comment

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

You forgot to change this coercion 🙈

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ohhh, you're right 😬. That's now fixed
The SecondOptionalParam check was also giving some errors in the tests -- so I decided to remove it until we can think of a better way to check this kind of params (maybe in V2).

@sampaiodiego sampaiodiego merged commit 301217a into develop May 21, 2021
@sampaiodiego sampaiodiego deleted the query-teams-members branch May 21, 2021 03:56
@sampaiodiego sampaiodiego mentioned this pull request May 28, 2021
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.

3 participants

Comments