aboutsummaryrefslogtreecommitdiffstats
path: root/packages/trpc/routers
diff options
context:
space:
mode:
authorMohamed Bassem <me@mbassem.com>2025-07-19 11:01:18 +0000
committerMohamed Bassem <me@mbassem.com>2025-07-19 11:02:03 +0000
commit4e9544b0c753b7fa01c56710a0d151e3a9f977e0 (patch)
tree623abb438668295a88f2d99515c94ab7c2a9eb5a /packages/trpc/routers
parent64a0d9185bf292ca0f4b407bfe302f6db7232493 (diff)
downloadkarakeep-4e9544b0c753b7fa01c56710a0d151e3a9f977e0.tar.zst
feat: Allow setting browserless crawling per user
Diffstat (limited to 'packages/trpc/routers')
-rw-r--r--packages/trpc/routers/admin.ts4
-rw-r--r--packages/trpc/routers/subscriptions.ts10
2 files changed, 13 insertions, 1 deletions
diff --git a/packages/trpc/routers/admin.ts b/packages/trpc/routers/admin.ts
index 2935f2e8..c4fc9d3d 100644
--- a/packages/trpc/routers/admin.ts
+++ b/packages/trpc/routers/admin.ts
@@ -361,6 +361,10 @@ export const adminAppRouter = router({
updateData.storageQuota = input.storageQuota;
}
+ if (input.browserCrawlingEnabled !== undefined) {
+ updateData.browserCrawlingEnabled = input.browserCrawlingEnabled;
+ }
+
if (Object.keys(updateData).length === 0) {
throw new TRPCError({
code: "BAD_REQUEST",
diff --git a/packages/trpc/routers/subscriptions.ts b/packages/trpc/routers/subscriptions.ts
index 4915a225..1cd34d30 100644
--- a/packages/trpc/routers/subscriptions.ts
+++ b/packages/trpc/routers/subscriptions.ts
@@ -90,12 +90,14 @@ async function syncStripeDataToDatabase(customerId: string, db: Context["db"]) {
})
.where(eq(subscriptions.stripeCustomerId, customerId));
- // Update user quotas to free tier limits
+ // Update user quotas to free tier limits and disable browser crawling
await trx
.update(users)
.set({
bookmarkQuota: serverConfig.quotas.free.bookmarkLimit,
storageQuota: serverConfig.quotas.free.assetSizeBytes,
+ browserCrawlingEnabled:
+ serverConfig.quotas.free.browserCrawlingEnabled,
})
.where(eq(users.id, existingSubscription.userId));
});
@@ -129,19 +131,25 @@ async function syncStripeDataToDatabase(customerId: string, db: Context["db"]) {
.where(eq(subscriptions.stripeCustomerId, customerId));
if (subData.status === "active" || subData.status === "trialing") {
+ // Enable paid tier quotas and browser crawling
await trx
.update(users)
.set({
bookmarkQuota: serverConfig.quotas.paid.bookmarkLimit,
storageQuota: serverConfig.quotas.paid.assetSizeBytes,
+ browserCrawlingEnabled:
+ serverConfig.quotas.paid.browserCrawlingEnabled,
})
.where(eq(users.id, existingSubscription.userId));
} else {
+ // Set free tier quotas and disable browser crawling
await trx
.update(users)
.set({
bookmarkQuota: serverConfig.quotas.free.bookmarkLimit,
storageQuota: serverConfig.quotas.free.assetSizeBytes,
+ browserCrawlingEnabled:
+ serverConfig.quotas.free.browserCrawlingEnabled,
})
.where(eq(users.id, existingSubscription.userId));
}