Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/wicked-chairs-compete.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": minor
---

Includes the voice call extension to the `users.autocomplete` endpoint resulting users properties
1 change: 1 addition & 0 deletions apps/meteor/app/api/server/lib/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export async function findUsersToAutocomplete({
nickname: 1,
status: 1,
avatarETag: 1,
freeSwitchExtension: 1,
},
sort: {
username: 1,
Expand Down
2 changes: 2 additions & 0 deletions apps/meteor/tests/data/users.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export const createUser = <TUser extends IUser>(
.post(api('users.create'))
.set(credentials)
.send({ email, name: username, username, password, ...userData })
// if we don't expect 200, there's never an error, even in the case of a failure result
.expect(200)
.end((err, res) => {
if (err) {
return reject(err);
Expand Down
43 changes: 33 additions & 10 deletions apps/meteor/tests/end-to-end/api/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4421,21 +4421,26 @@ describe('[Users]', () => {
this.timeout(20000);

before(async () => {
user = await createUser({ joinDefaultChannels: false });
user2 = await createUser({ joinDefaultChannels: false });
const users = await Promise.all([createUser({ joinDefaultChannels: false }), createUser({ joinDefaultChannels: false })]);

userCredentials = await login(user.username, password);
user2Credentials = await login(user2.username, password);
user = users[0];
user2 = users[1];

await updatePermission('view-outside-room', []);
const credentials = await Promise.all([
login(user.username, password),
login(user2.username, password),
await updatePermission('view-outside-room', []),
]);

userCredentials = credentials[0];
user2Credentials = credentials[1];

roomId = (await createRoom({ type: 'c', credentials: userCredentials, name: `channel.autocomplete.${Date.now()}` })).body.channel
._id;
});

after(async () => {
await deleteRoom({ type: 'c', roomId });
await Promise.all([deleteUser(user), deleteUser(user2)]);
await Promise.all([deleteRoom({ type: 'c', roomId }), deleteUser(user), deleteUser(user2)]);
});

it('should return an empty list when the user does not have any subscription', (done) => {
Expand Down Expand Up @@ -4469,9 +4474,9 @@ describe('[Users]', () => {
});

describe('[with permission]', () => {
before(() => updatePermission('view-outside-room', ['admin', 'user']));
before(async () => updatePermission('view-outside-room', ['admin', 'user']));

it('should return an error when the required parameter "selector" is not provided', () => {
it('should return an error when the required parameter "selector" is not provided', (done) => {
void request
.get(api('users.autocomplete'))
.query({})
Expand All @@ -4480,7 +4485,8 @@ describe('[Users]', () => {
.expect(400)
.expect((res) => {
expect(res.body).to.have.property('success', false);
});
})
.end(done);
});
it('should return the users to fill auto complete', (done) => {
void request
Expand All @@ -4496,6 +4502,23 @@ describe('[Users]', () => {
.end(done);
});

(IS_EE ? it : it.skip)('should return users filtered by freeSwitchExtension and display it', async () => {
const user = await createUser({ joinDefaultChannels: false, freeSwitchExtension: '1234567890' });
await request
.get(api('users.autocomplete'))
.query({ selector: JSON.stringify({ conditions: { freeSwitchExtension: '1234567890' } }) })
.set(credentials)
.expect('Content-Type', 'application/json')
.expect(200)
.expect((res) => {
expect(res.body).to.have.property('success', true);
expect(res.body).to.have.property('items').and.to.be.an('array').with.lengthOf(1);
expect(res.body.items[0]).to.have.property('freeSwitchExtension', '1234567890');
});

await deleteUser(user);
});

it('should filter results when using allowed operators', (done) => {
void request
.get(api('users.autocomplete'))
Expand Down
Loading