Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

core: limit notebooks to 20 on basic plan

Abdullah Attacf4a7a3d34a9
diff --git a/packages/core/src/collections/notebooks.ts b/packages/core/src/collections/notebooks.ts
index 3597574ed..45144ccec 100644
--- a/packages/core/src/collections/notebooks.ts
+++ b/packages/core/src/collections/notebooks.ts
@@ -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";
@@ -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