MCPcopy Create free account
hub / github.com/dfinity/orbit / list_users

Method list_users

core/station/impl/src/services/user.rs:202–240  ·  view source on GitHub ↗

Returns the list of users from the given pagination parameters. The default limit is 100 and the maximum limit is 1000.

(
        &self,
        input: ListUsersInput,
        ctx: Option<&CallContext>,
    )

Source from the content-addressed store, hash-verified

200 ///
201 /// The default limit is 100 and the maximum limit is 1000.
202 pub async fn list_users(
203 &self,
204 input: ListUsersInput,
205 ctx: Option<&CallContext>,
206 ) -> ServiceResult<PaginatedData<User>> {
207 let mut users = self.user_repository.find_where(UserWhereClause {
208 search_term: input.search_term,
209 groups: input.groups.map(|groups| {
210 groups
211 .into_iter()
212 .filter_map(|group_id| {
213 HelperMapper::to_uuid(group_id)
214 .map(|id| id.as_bytes().to_owned())
215 .ok()
216 })
217 .collect()
218 }),
219 statuses: input
220 .statuses
221 .map(|statuses| statuses.into_iter().map(Into::into).collect()),
222 });
223
224 // filter out users that the caller does not have access to read
225 if let Some(ctx) = ctx {
226 retain_accessible_resources(ctx, &mut users, |user| {
227 Resource::User(UserResourceAction::Read(ResourceId::Id(user.id)))
228 });
229 }
230
231 let result = paginated_items(PaginatedItemsArgs {
232 offset: input.paginate.to_owned().and_then(|p| p.offset),
233 limit: input.paginate.and_then(|p| p.limit),
234 default_limit: Some(Self::DEFAULT_USER_LIST_LIMIT),
235 max_limit: Some(Self::MAX_USER_LIST_LIMIT),
236 items: &users,
237 })?;
238
239 Ok(result)
240 }
241
242 /// Returns the user privileges from the given user.
243 pub async fn get_caller_privileges(

Callers 3

listUsersMethod · 0.45
listUsersFunction · 0.45

Calls 5

mapMethod · 0.80
UserClass · 0.50
paginated_itemsFunction · 0.50
find_whereMethod · 0.45

Tested by

no test coverage detected