A possible use-case may reqquire disabling user search. User search is possible through the queryUsers endpoint.
By default, queryUsers is an endpoint that doesn't require any special permissions. It is available to all users, channel_member, channel_moderator, and admin -
const usersList = await client.queryUsers({});
This returns all the users from the app -
{
users: [
{
id: 'User1',
role: 'channel_moderator',
created_at: '2020-11-18T02:46:53.814791Z',
updated_at: '2020-12-16T04:22:20.834989Z',
last_active: '2020-12-16T04:19:39.361607Z',
banned: false,
online: true,
shadow_banned: false,
image: 'https://getstream.io/random_svg/?name=user1'
},
{
id: 'User2',
role: 'channel_member',
created_at: '2020-11-16T05:17:11.898584Z',
updated_at: '2020-11-16T05:17:11.899591Z',
banned: false,
online: false,
shadow_banned: false,
book: 'boom',
name: 'User2'
},
]
}
To disable this query for users and the admins do this -
return await client.updateAppSettings({
user_search_disallowed_roles: ["user", "admin"]
});
Once this permission update is done, the error bellow will log when attempting to use the queryUser endpoint:
UnhandledPromiseRejectionWarning: Error: StreamChat error code 17:
QueryUsers failed with error: "users with role "user" are not allowed
to use this endpoint"
UnhandledPromiseRejectionWarning: Error: StreamChat error code 17:
QueryUsers failed with error: "users with role "admin" are not allowed
to use this endpoint"
Comments
0 comments
Please sign in to leave a comment.