-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMPROVE] Add support to queries in
channels.members
and `groups.me…
…mbers` endpoints (#21414) Co-authored-by: Diego Sampaio <chinello@gmail.com>
- Loading branch information
1 parent
c2e99d3
commit 35b497c
Showing
5 changed files
with
95 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import type { Mongo } from 'meteor/mongo'; | ||
|
||
import { Users } from '../../app/models/server'; | ||
import { settings } from '../../app/settings/server'; | ||
import { IUser } from '../../definition/IUser'; | ||
|
||
type FindUsersParam = { | ||
rid: string; | ||
status?: string; | ||
skip?: number; | ||
limit?: number; | ||
filter?: string; | ||
sort?: Record<string, any>; | ||
}; | ||
|
||
export function findUsersOfRoom({ rid, status, skip = 0, limit = 0, filter = '', sort = {} }: FindUsersParam): Mongo.Cursor<IUser> { | ||
const options = { | ||
fields: { | ||
name: 1, | ||
username: 1, | ||
nickname: 1, | ||
status: 1, | ||
avatarETag: 1, | ||
_updatedAt: 1, | ||
}, | ||
sort: { | ||
statusConnection: -1, | ||
...sort || { [settings.get('UI_Use_Real_Name') ? 'name' : 'username']: 1 }, | ||
}, | ||
...skip > 0 && { skip }, | ||
...limit > 0 && { limit }, | ||
}; | ||
|
||
return Users.findByActiveUsersExcept(filter, undefined, options, undefined, [{ | ||
__rooms: rid, | ||
...status && { status }, | ||
}]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters