Skip to content

Commit

Permalink
refactor!: removed roomNameExists method (#32484)
Browse files Browse the repository at this point in the history
Co-authored-by: Marcos Spessatto Defendi <[email protected]>
  • Loading branch information
2 people authored and ggazzo committed Sep 14, 2024
1 parent 7778f38 commit 010dfd6
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 37 deletions.
4 changes: 3 additions & 1 deletion apps/meteor/app/api/server/v1/rooms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ API.v1.addRoute(
async get() {
const { roomName } = this.queryParams;

return API.v1.success({ exists: await Meteor.callAsync('roomNameExists', roomName) });
const room = await Rooms.findOneByName(roomName, { projection: { _id: 1 } });

return API.v1.success({ exists: !!room });
},
},
);
Expand Down
1 change: 0 additions & 1 deletion apps/meteor/server/methods/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ import './removeUserFromRoom';
import './reportMessage';
import './requestDataDownload';
import './resetAvatar';
import './roomNameExists';
import './saveUserPreferences';
import './saveUserProfile';
import './sendConfirmationEmail';
Expand Down
34 changes: 0 additions & 34 deletions apps/meteor/server/methods/roomNameExists.ts

This file was deleted.

17 changes: 16 additions & 1 deletion apps/meteor/tests/end-to-end/api/rooms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -941,7 +941,22 @@ describe('[Rooms]', () => {
.end(done);
});

it('should return an error when send an invalid room', (done) => {
it('should return false if this room name does not exist', (done) => {
void request
.get(api('rooms.nameExists'))
.set(credentials)
.query({
roomName: 'foo',
})
.expect(200)
.expect((res) => {
expect(res.body).to.have.property('success', true);
expect(res.body).to.have.property('exists', false);
})
.end(done);
});

it('should return an error when the require parameter (roomName) is not provided', (done) => {
void request
.get(api('rooms.nameExists'))
.set(credentials)
Expand Down

0 comments on commit 010dfd6

Please sign in to comment.