make pinned post limit configurable

This commit is contained in:
nelle 2024-06-17 10:37:56 -06:00
parent 6c2131fdcc
commit a44a89276d
4 changed files with 8 additions and 1 deletions

View file

@ -180,6 +180,9 @@ reservedUsernames: [
# notFound: '/twemoji/2049.svg' # notFound: '/twemoji/2049.svg'
# error: '/twemoji/1f480.svg' # error: '/twemoji/1f480.svg'
# Pinned Post Limit
# pinLimit: 5
# Search engine (MFM) # Search engine (MFM)
#searchEngine: 'https://duckduckgo.com/?q=' #searchEngine: 'https://duckduckgo.com/?q='

View file

@ -54,6 +54,8 @@ export default function load() {
...config.images, ...config.images,
}; };
config.pinLimit = config.pinLimit || parseInt(process.env.pinLimit || "", 100);
config.htmlCache = { config.htmlCache = {
ttlSeconds: parseDuration(config.htmlCache?.ttl ?? '1h', 's')!, ttlSeconds: parseDuration(config.htmlCache?.ttl ?? '1h', 's')!,
prewarm: false, prewarm: false,

View file

@ -53,6 +53,8 @@ export type Source = {
info?: string; info?: string;
}; };
pinLimit?: number;
htmlCache?: { htmlCache?: {
ttl?: string; ttl?: string;
ttlSeconds?: number; ttlSeconds?: number;

View file

@ -35,7 +35,7 @@ export async function addPinned(
const pinings = await UserNotePinings.findBy({ userId: user.id }); const pinings = await UserNotePinings.findBy({ userId: user.id });
if (pinings.length >= 5) { if (pinings.length >= config.pinLimit) {
throw new IdentifiableError( throw new IdentifiableError(
"15a018eb-58e5-4da1-93be-330fcc5e4e1a", "15a018eb-58e5-4da1-93be-330fcc5e4e1a",
"You can not pin notes any more.", "You can not pin notes any more.",