From 3c2eeaf16d808481fc6975e4498168dd92e34450 Mon Sep 17 00:00:00 2001 From: riku6460 <17585784+riku6460@users.noreply.github.com> Date: Mon, 11 Mar 2024 09:23:50 +0900 Subject: [PATCH] =?UTF-8?q?=E3=82=A2=E3=83=B3=E3=83=86=E3=83=8A=E3=81=AB?= =?UTF-8?q?=E4=BF=9D=E6=8C=81=E3=81=99=E3=82=8B=E6=9C=80=E5=A4=A7=E3=83=8E?= =?UTF-8?q?=E3=83=BC=E3=83=88=E6=95=B0=E3=81=AE=E8=A8=AD=E5=AE=9A=E3=81=8C?= =?UTF-8?q?=E6=A9=9F=E8=83=BD=E3=81=97=E3=81=A6=E3=81=84=E3=81=AA=E3=81=84?= =?UTF-8?q?=E5=95=8F=E9=A1=8C=E3=82=92=E4=BF=AE=E6=AD=A3=20(#517)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/backend/src/core/AntennaService.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/backend/src/core/AntennaService.ts b/packages/backend/src/core/AntennaService.ts index adddd29ebc..c148cf5476 100644 --- a/packages/backend/src/core/AntennaService.ts +++ b/packages/backend/src/core/AntennaService.ts @@ -17,7 +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 { RolePolicies, RoleService } from '@/core/RoleService.js'; import type { OnApplicationShutdown } from '@nestjs/common'; @Injectable() @@ -104,9 +104,13 @@ export class AntennaService implements OnApplicationShutdown { const redisPipeline = this.redisForTimelines.pipeline(); - const { antennaNotesLimit } = await this.roleService.getUserPolicies(noteUser.id); + const policies = new Map((await Promise.allSettled(Array.from(new Set(matchedAntennas.map(antenna => antenna.userId))).map(async userId => [userId, await this.roleService.getUserPolicies(userId)] as const))) + .filter((result): result is PromiseFulfilledResult<[string, RolePolicies]> => result.status === 'fulfilled') + .map(result => result.value)); for (const antenna of matchedAntennas) { + const { antennaNotesLimit } = policies.get(antenna.userId) ?? await this.roleService.getUserPolicies(antenna.userId); + this.fanoutTimelineService.push(`antennaTimeline:${antenna.id}`, note.id, antennaNotesLimit, redisPipeline); this.globalEventService.publishAntennaStream(antenna.id, 'note', note); }