mirror of
https://iceshrimp.dev/limepotato/jormungandr-patches.git
synced 2024-11-12 14:17:27 -07:00
65 lines
2.1 KiB
Diff
65 lines
2.1 KiB
Diff
From a44a89276deb372965423245155d9fdbf90abf4a Mon Sep 17 00:00:00 2001
|
|
From: limepotato <bm01@limepot.xyz>
|
|
Date: Mon, 17 Jun 2024 10:37:56 -0600
|
|
Subject: [PATCH] make pinned post limit configurable
|
|
|
|
---
|
|
.config/example.yml | 3 +++
|
|
packages/backend/src/config/load.ts | 2 ++
|
|
packages/backend/src/config/types.ts | 2 ++
|
|
packages/backend/src/services/i/pin.ts | 2 +-
|
|
4 files changed, 8 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/.config/example.yml b/.config/example.yml
|
|
index f7bd14292..08a9cc473 100644
|
|
--- a/.config/example.yml
|
|
+++ b/.config/example.yml
|
|
@@ -180,6 +180,9 @@ reservedUsernames: [
|
|
# notFound: '/twemoji/2049.svg'
|
|
# error: '/twemoji/1f480.svg'
|
|
|
|
+# Pinned Post Limit
|
|
+#pinLimit: 5
|
|
+
|
|
# Search engine (MFM)
|
|
#searchEngine: 'https://duckduckgo.com/?q='
|
|
|
|
diff --git a/packages/backend/src/config/load.ts b/packages/backend/src/config/load.ts
|
|
index 0c1971cdd..34b667226 100644
|
|
--- a/packages/backend/src/config/load.ts
|
|
+++ b/packages/backend/src/config/load.ts
|
|
@@ -54,6 +54,8 @@ export default function load() {
|
|
...config.images,
|
|
};
|
|
|
|
+ config.pinLimit = config.pinLimit || parseInt(process.env.pinLimit || "", 100);
|
|
+
|
|
config.htmlCache = {
|
|
ttlSeconds: parseDuration(config.htmlCache?.ttl ?? '1h', 's')!,
|
|
prewarm: false,
|
|
diff --git a/packages/backend/src/config/types.ts b/packages/backend/src/config/types.ts
|
|
index a8566cb31..bdfadc7f4 100644
|
|
--- a/packages/backend/src/config/types.ts
|
|
+++ b/packages/backend/src/config/types.ts
|
|
@@ -53,6 +53,8 @@ export type Source = {
|
|
info?: string;
|
|
};
|
|
|
|
+ pinLimit?: number;
|
|
+
|
|
htmlCache?: {
|
|
ttl?: string;
|
|
ttlSeconds?: number;
|
|
diff --git a/packages/backend/src/services/i/pin.ts b/packages/backend/src/services/i/pin.ts
|
|
index 97045a9fa..d4d8578f8 100644
|
|
--- a/packages/backend/src/services/i/pin.ts
|
|
+++ b/packages/backend/src/services/i/pin.ts
|
|
@@ -35,7 +35,7 @@ export async function addPinned(
|
|
|
|
const pinings = await UserNotePinings.findBy({ userId: user.id });
|
|
|
|
- if (pinings.length >= 5) {
|
|
+ if (pinings.length >= config.pinLimit) {
|
|
throw new IdentifiableError(
|
|
"15a018eb-58e5-4da1-93be-330fcc5e4e1a",
|
|
"You can not pin notes any more.",
|