fixed adding new workspace at login
This commit is contained in:
@@ -114,6 +114,24 @@ export const ensurePersonalWorkspaceForUser = async (user: UserRow) => {
|
||||
return workspaceId;
|
||||
};
|
||||
|
||||
export const ensureDefaultWorkspaceForUser = async (user: UserRow) => {
|
||||
const existing = await db.query<{ workspace_id: number }>(
|
||||
`SELECT workspace_id
|
||||
FROM workspace_members
|
||||
INNER JOIN workspaces ON workspaces.id = workspace_members.workspace_id
|
||||
WHERE workspace_members.user_id = $1
|
||||
ORDER BY workspaces.created_at ASC
|
||||
LIMIT 1`,
|
||||
[user.id],
|
||||
);
|
||||
|
||||
if (existing.rowCount) {
|
||||
return Number(existing.rows[0].workspace_id);
|
||||
}
|
||||
|
||||
return ensurePersonalWorkspaceForUser(user);
|
||||
};
|
||||
|
||||
export const claimWorkspaceInvites = async (user: UserRow) => {
|
||||
await db.query(
|
||||
`UPDATE workspace_members
|
||||
|
||||
Reference in New Issue
Block a user