feat: 通知の保存上限を変更可能に
This commit is contained in:
parent
9a688dde0a
commit
dcc5341f51
|
@ -91,6 +91,7 @@ export type Source = {
|
||||||
nirila?: {
|
nirila?: {
|
||||||
abuseDiscordHook: string;
|
abuseDiscordHook: string;
|
||||||
disableAbuseRepository?: boolean;
|
disableAbuseRepository?: boolean;
|
||||||
|
notificationLimit?: number;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ import { PushNotificationService } from '@/core/PushNotificationService.js';
|
||||||
import { NotificationEntityService } from '@/core/entities/NotificationEntityService.js';
|
import { NotificationEntityService } from '@/core/entities/NotificationEntityService.js';
|
||||||
import { IdService } from '@/core/IdService.js';
|
import { IdService } from '@/core/IdService.js';
|
||||||
import { CacheService } from '@/core/CacheService.js';
|
import { CacheService } from '@/core/CacheService.js';
|
||||||
|
import type { Config } from '@/config.js';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class NotificationService implements OnApplicationShutdown {
|
export class NotificationService implements OnApplicationShutdown {
|
||||||
|
@ -31,6 +32,9 @@ export class NotificationService implements OnApplicationShutdown {
|
||||||
@Inject(DI.mutingsRepository)
|
@Inject(DI.mutingsRepository)
|
||||||
private mutingsRepository: MutingsRepository,
|
private mutingsRepository: MutingsRepository,
|
||||||
|
|
||||||
|
@Inject(DI.config)
|
||||||
|
private config: Config,
|
||||||
|
|
||||||
private notificationEntityService: NotificationEntityService,
|
private notificationEntityService: NotificationEntityService,
|
||||||
private userEntityService: UserEntityService,
|
private userEntityService: UserEntityService,
|
||||||
private idService: IdService,
|
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 = {
|
const notification = {
|
||||||
id: this.idService.genId(),
|
id: this.idService.genId(),
|
||||||
createdAt: new Date(),
|
createdAt: new Date(),
|
||||||
|
@ -99,7 +106,7 @@ export class NotificationService implements OnApplicationShutdown {
|
||||||
|
|
||||||
const redisIdPromise = this.redisClient.xadd(
|
const redisIdPromise = this.redisClient.xadd(
|
||||||
`notificationTimeline:${notifieeId}`,
|
`notificationTimeline:${notifieeId}`,
|
||||||
'MAXLEN', '~', '300',
|
'MAXLEN', '~', `${notificationLimit}`,
|
||||||
'*',
|
'*',
|
||||||
'data', JSON.stringify(notification));
|
'data', JSON.stringify(notification));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue