We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9184e1a commit b8ecaf2Copy full SHA for b8ecaf2
server/apis/workspace/service.ts
@@ -27,6 +27,14 @@ export const join = async (userId: number, code: string) => {
27
28
const { id, name } = workspace;
29
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
38
await workspaceModel.updateOne({ id }, { $addToSet: { users: userId } });
39
await userModel.updateOne({ id: userId }, { $addToSet: { workspaces: id } });
40
0 commit comments