feat: 通知の保存上限を変更可能に
This commit is contained in:
parent
9a688dde0a
commit
dcc5341f51
|
@ -91,6 +91,7 @@ export type Source = {
|
|||
nirila?: {
|
||||
abuseDiscordHook: string;
|
||||
disableAbuseRepository?: boolean;
|
||||
notificationLimit?: number;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -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));
|
||||
|
||||
|
|
Loading…
Reference in New Issue