Skip to content

Commit b8ecaf2

Browse files
juyeong-sse030
andcommitted
feat : 이미 참여한 워크스페이스 에러 뱉기
Co-authored-by: 산타클로스 <[email protected]>
1 parent 9184e1a commit b8ecaf2

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

server/apis/workspace/service.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@ export const join = async (userId: number, code: string) => {
2727

2828
const { id, name } = workspace;
2929

30+
const userWorkspaces = (
31+
await userModel.find({ id: userId }, { workspaces: 1, _id: 0 })
32+
)[0].workspaces;
33+
34+
if (userWorkspaces.includes(id)) {
35+
throw new Error('이미 참여한 워크스페이스에요 ^^');
36+
}
37+
3038
await workspaceModel.updateOne({ id }, { $addToSet: { users: userId } });
3139
await userModel.updateOne({ id: userId }, { $addToSet: { workspaces: id } });
3240

0 commit comments

Comments
 (0)