Skip to content

Commit

Permalink
core: limit notebooks to 20 on basic plan
Browse files Browse the repository at this point in the history
  • Loading branch information
thecodrr committed Aug 16, 2024
1 parent 86e661c commit cf4a7a3
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/core/src/collections/notebooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { SQLCollection } from "../database/sql-collection";
import { isFalse } from "../database";
import { sql } from "kysely";
import { deleteItems } from "../utils/array";
import { CHECK_IDS, checkIsUserPremium } from "../common";

export class Notebooks implements ICollection {
name = "notebooks";
Expand Down Expand Up @@ -59,6 +60,13 @@ export class Notebooks implements ICollection {
if (oldNotebook && isTrashItem(oldNotebook))
throw new Error("Cannot modify trashed notebooks.");

if (
!oldNotebook &&
(await this.all.count()) >= 20 &&
!(await checkIsUserPremium(CHECK_IDS.notebookAdd))
)
return;

const mergedNotebook: Partial<Notebook> = {
...oldNotebook,
...notebookArg
Expand Down

0 comments on commit cf4a7a3

Please sign in to comment.