Skip to content

Commit d50d008

Browse files
Add isActive to db fetches where necessary
1 parent 199c2bd commit d50d008

13 files changed

Lines changed: 30 additions & 10 deletions

File tree

docs/api-reference/sourcebot-public.openapi.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1148,6 +1148,9 @@
11481148
"MEMBER"
11491149
]
11501150
},
1151+
"isActive": {
1152+
"type": "boolean"
1153+
},
11511154
"createdAt": {
11521155
"type": "string",
11531156
"format": "date-time"
@@ -1163,6 +1166,7 @@
11631166
"name",
11641167
"email",
11651168
"role",
1169+
"isActive",
11661170
"createdAt",
11671171
"lastActivityAt"
11681172
]

packages/web/src/app/(app)/layout.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,13 @@ export default async function Layout(props: LayoutProps) {
6161

6262
// If the user is authenticated, we must check if they're a member of the org
6363
if (session) {
64-
const membership = await __unsafePrisma.userToOrg.findUnique({
64+
const activeMembership = await __unsafePrisma.userToOrg.findUnique({
6565
where: {
6666
orgId_userId: {
6767
orgId: org.id,
68-
userId: session.user.id
69-
}
68+
userId: session.user.id,
69+
},
70+
isActive: true,
7071
},
7172
include: {
7273
user: true
@@ -77,7 +78,7 @@ export default async function Layout(props: LayoutProps) {
7778
// 1. The org doesn't require member approval, but the org was at max capacity when the user registered. In this case, we show them
7879
// the join organization card to allow them to join the org if seat capacity is freed up. This card handles checking if the org has available seats.
7980
// 2. The org requires member approval, and they haven't been approved yet. In this case, we allow them to submit a request to join the org.
80-
if (!membership) {
81+
if (!activeMembership) {
8182
if (await isScimEnabled(org)) {
8283
return <NotProvisionedCard />;
8384
}
@@ -100,7 +101,7 @@ export default async function Layout(props: LayoutProps) {
100101
}
101102
}
102103

103-
role = membership.role;
104+
role = activeMembership.role;
104105
} else {
105106
// If the user isn't authenticated and anonymous access isn't enabled, we need to redirect them to the login page.
106107
if (!anonymousAccessEnabled) {

packages/web/src/app/(app)/settings/license/page.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,12 @@ export default authenticatedPage<LicensePageProps>(async ({ prisma, org }, props
4949
: await prisma.license.findUnique({ where: { orgId: org.id } });
5050

5151
const yearlyTermStatus = getYearlyTermStatus(license);
52-
const currentUserCount = await prisma.userToOrg.count({ where: { orgId: org.id } });
52+
const currentActiveUserCount = await prisma.userToOrg.count({
53+
where: {
54+
orgId: org.id,
55+
isActive: true,
56+
},
57+
});
5358

5459
const invoicesResult = license ? await getAllInvoices() : null;
5560
const invoices = invoicesResult && !isServiceError(invoicesResult) ? invoicesResult : [];
@@ -97,7 +102,7 @@ export default authenticatedPage<LicensePageProps>(async ({ prisma, org }, props
97102
&& !isOnlineLicenseInactive
98103
&& yearlyTermStatus && (
99104
<YearlyTermSeatsUsageCard
100-
currentUsers={currentUserCount}
105+
currentUsers={currentActiveUserCount}
101106
status={yearlyTermStatus}
102107
/>
103108
)}

packages/web/src/app/api/(server)/ee/askmcp/callback/route.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ export const GET = apiHandler(async (request: NextRequest) => {
153153
orgId: userServer.server.orgId,
154154
userId: session.user.id,
155155
},
156+
isActive: true,
156157
},
157158
});
158159

packages/web/src/app/api/(server)/ee/chat/[chatId]/searchMembers/route.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ export const GET = apiHandler(async (
111111
{ email: { contains: query, mode: 'insensitive' } },
112112
],
113113
},
114+
isActive: true,
114115
},
115116
include: {
116117
user: true,

packages/web/src/app/api/(server)/ee/users/route.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ export const GET = apiHandler(async () => {
5656
name: membership.user.name,
5757
email: membership.user.email,
5858
role: membership.role,
59+
isActive: membership.isActive,
5960
createdAt: membership.user.createdAt,
6061
lastActivityAt: lastActivity?.timestamp ?? null,
6162
};

packages/web/src/app/invite/page.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ export default async function InvitePage(props: InvitePageProps) {
3737
orgId_userId: {
3838
orgId: org.id,
3939
userId: session.user.id
40-
}
40+
},
41+
isActive: true,
4142
}
4243
});
4344

packages/web/src/app/onboard/page.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ export default async function Onboarding(props: OnboardingProps) {
5050
orgId_userId: {
5151
orgId: org.id,
5252
userId: session.user.id
53-
}
53+
},
54+
isActive: true,
5455
}
5556
});
5657

packages/web/src/app/redeem/page.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ export default async function RedeemPage(props: RedeemPageProps) {
3838
orgId_userId: {
3939
orgId: org.id,
4040
userId: session.user.id
41-
}
41+
},
42+
isActive: true,
4243
}
4344
});
4445

packages/web/src/features/billing/actions.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ export const createCheckoutSession = async ({
130130
const memberCount = await prisma.userToOrg.count({
131131
where: {
132132
orgId: org.id,
133+
isActive: true,
133134
},
134135
});
135136
const quantity = Math.max(memberCount, 1);

0 commit comments

Comments
 (0)