diff --git a/packages/backend/src/config.ts b/packages/backend/src/config.ts index a41fd8b38a..f2587ab52a 100644 --- a/packages/backend/src/config.ts +++ b/packages/backend/src/config.ts @@ -91,6 +91,7 @@ export type Source = { nirila?: { abuseDiscordHook: string; disableAbuseRepository?: boolean; + notificationLimit?: number; } }; diff --git a/packages/backend/src/core/NotificationService.ts b/packages/backend/src/core/NotificationService.ts index 8e25f82284..587176fe56 100644 --- a/packages/backend/src/core/NotificationService.ts +++ b/packages/backend/src/core/NotificationService.ts @@ -13,6 +13,7 @@ import { PushNotificationService } from '@/core/PushNotificationService.js'; import { NotificationEntityService } from '@/core/entities/NotificationEntityService.js'; import { IdService } from '@/core/IdService.js'; import { CacheService } from '@/core/CacheService.js'; +import type { Config } from '@/config.js'; @Injectable() export class NotificationService implements OnApplicationShutdown { @@ -31,6 +32,9 @@ export class NotificationService implements OnApplicationShutdown { @Inject(DI.mutingsRepository) private mutingsRepository: MutingsRepository, + @Inject(DI.config) + private config: Config, + private notificationEntityService: NotificationEntityService, private userEntityService: UserEntityService, private idService: IdService, @@ -90,6 +94,9 @@ export class NotificationService implements OnApplicationShutdown { } } + let notificationLimit = this.config.nirila?.notificationLimit; + if (!Number.isInteger(notificationLimit)) notificationLimit = 300; + const notification = { id: this.idService.genId(), createdAt: new Date(), @@ -99,7 +106,7 @@ export class NotificationService implements OnApplicationShutdown { const redisIdPromise = this.redisClient.xadd( `notificationTimeline:${notifieeId}`, - 'MAXLEN', '~', '300', + 'MAXLEN', '~', `${notificationLimit}`, '*', 'data', JSON.stringify(notification));