Skip to content

Commit 8e5169c

Browse files
committed
make addUserToRoom to receive user instead of user or string
1 parent e5f655b commit 8e5169c

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

apps/meteor/app/lib/server/functions/addUserToRoom.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { notifyOnRoomChangedById, notifyOnSubscriptionChangedById } from '../lib
2121

2222
export const addUserToRoom = async (
2323
rid: string,
24-
user: Pick<IUser, '_id' | 'username'> | string,
24+
user: Pick<IUser, '_id' | 'username'>,
2525
inviter?: Pick<IUser, '_id' | 'username'>,
2626
{
2727
skipSystemMessage,
@@ -42,7 +42,7 @@ export const addUserToRoom = async (
4242
});
4343
}
4444

45-
const userToBeAdded = typeof user === 'string' ? await Users.findOneByUsername(user.replace('@', '')) : await Users.findOneById(user._id);
45+
const userToBeAdded = await Users.findOneById(user._id);
4646
const roomDirectives = roomCoordinator.getRoomDirectives(room.t);
4747

4848
if (!userToBeAdded) {

apps/meteor/app/lib/server/methods/addUsersToRoom.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export const sanitizeUsername = (username: string) => {
2323
if (isFederatedUsername) {
2424
return username;
2525
}
26-
26+
2727
return username.replace(/(^@)|( @)/, '');
2828
};
2929

@@ -103,7 +103,7 @@ export const addUsersToRoomMethod = async (userId: string, data: { rid: string;
103103

104104
const subscription = await Subscriptions.findOneByRoomIdAndUserId(data.rid, newUser._id);
105105
if (!subscription) {
106-
await addUserToRoom(data.rid, newUser || username, user);
106+
await addUserToRoom(data.rid, newUser, user);
107107
} else {
108108
if (!newUser.username) {
109109
return;

0 commit comments

Comments
 (0)