feat: アンテナに保持するノート数をポリシーに追加 (MisskeyIO#499)

This commit is contained in:
kabo2468 2024-03-03 02:42:13 +09:00 committed by GitHub
parent a24e93ec6c
commit c0dbdd78c1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 46 additions and 1 deletions

View file

@ -17,6 +17,7 @@ import { UtilityService } from '@/core/UtilityService.js';
import { bindThis } from '@/decorators.js';
import type { GlobalEvents } from '@/core/GlobalEventService.js';
import { FanoutTimelineService } from '@/core/FanoutTimelineService.js';
import { RoleService } from '@/core/RoleService.js';
import type { OnApplicationShutdown } from '@nestjs/common';
@Injectable()
@ -40,6 +41,7 @@ export class AntennaService implements OnApplicationShutdown {
private utilityService: UtilityService,
private globalEventService: GlobalEventService,
private fanoutTimelineService: FanoutTimelineService,
private roleService: RoleService,
) {
this.antennasFetched = false;
this.antennas = [];
@ -102,8 +104,10 @@ export class AntennaService implements OnApplicationShutdown {
const redisPipeline = this.redisForTimelines.pipeline();
const { antennaNotesLimit } = await this.roleService.getUserPolicies(noteUser.id);
for (const antenna of matchedAntennas) {
this.fanoutTimelineService.push(`antennaTimeline:${antenna.id}`, note.id, 200, redisPipeline);
this.fanoutTimelineService.push(`antennaTimeline:${antenna.id}`, note.id, antennaNotesLimit, redisPipeline);
this.globalEventService.publishAntennaStream(antenna.id, 'note', note);
}

View file

@ -57,6 +57,7 @@ export type RolePolicies = {
alwaysMarkNsfw: boolean;
pinLimit: number;
antennaLimit: number;
antennaNotesLimit: number;
wordMuteLimit: number;
webhookLimit: number;
clipLimit: number;
@ -92,6 +93,7 @@ export const DEFAULT_POLICIES: RolePolicies = {
alwaysMarkNsfw: false,
pinLimit: 5,
antennaLimit: 5,
antennaNotesLimit: 200,
wordMuteLimit: 200,
webhookLimit: 3,
clipLimit: 10,
@ -366,6 +368,7 @@ export class RoleService implements OnApplicationShutdown, OnModuleInit {
alwaysMarkNsfw: calc('alwaysMarkNsfw', vs => vs.some(v => v === true)),
pinLimit: calc('pinLimit', vs => Math.max(...vs)),
antennaLimit: calc('antennaLimit', vs => Math.max(...vs)),
antennaNotesLimit: calc('antennaNotesLimit', vs => Math.max(...vs)),
wordMuteLimit: calc('wordMuteLimit', vs => Math.max(...vs)),
webhookLimit: calc('webhookLimit', vs => Math.max(...vs)),
clipLimit: calc('clipLimit', vs => Math.max(...vs)),