From 40422e01884a94b5fcfbde780e28d6ef637d1a93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=BE=E3=81=A3=E3=81=A1=E3=82=83=E3=81=A8=E3=83=BC?= =?UTF-8?q?=E3=81=AB=E3=82=85?= <17376330+u1-liquid@users.noreply.github.com> Date: Wed, 6 Dec 2023 02:59:17 +0900 Subject: [PATCH] =?UTF-8?q?enhance(backend):=20=E3=83=A6=E3=83=BC=E3=82=B6?= =?UTF-8?q?=E3=83=BC=E3=81=AE=E3=83=AA=E3=82=A2=E3=82=AF=E3=82=B7=E3=83=A7?= =?UTF-8?q?=E3=83=B3=E3=81=AE=E4=B8=80=E8=A6=A7API=E3=81=AE=E3=83=91?= =?UTF-8?q?=E3=83=95=E3=82=A9=E3=83=BC=E3=83=9E=E3=83=B3=E3=82=B9=E3=81=AE?= =?UTF-8?q?=E6=94=B9=E5=96=84=20(MisskeyIO#278)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/api/endpoints/users/reactions.ts | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/packages/backend/src/server/api/endpoints/users/reactions.ts b/packages/backend/src/server/api/endpoints/users/reactions.ts index 8ad99b8dc0..292af4e12e 100644 --- a/packages/backend/src/server/api/endpoints/users/reactions.ts +++ b/packages/backend/src/server/api/endpoints/users/reactions.ts @@ -4,12 +4,13 @@ */ import { Inject, Injectable } from '@nestjs/common'; -import type { UserProfilesRepository, NoteReactionsRepository } from '@/models/_.js'; +import type { UserProfilesRepository, NotesRepository, NoteReactionsRepository } from '@/models/_.js'; import { Endpoint } from '@/server/api/endpoint-base.js'; import { QueryService } from '@/core/QueryService.js'; import { NoteReactionEntityService } from '@/core/entities/NoteReactionEntityService.js'; import { DI } from '@/di-symbols.js'; import { ApiError } from '../../error.js'; +import { MiNoteReaction } from "@/models/_.js"; export const meta = { tags: ['users', 'reactions'], @@ -56,6 +57,9 @@ export default class extends Endpoint { // eslint- @Inject(DI.userProfilesRepository) private userProfilesRepository: UserProfilesRepository, + @Inject(DI.notesRepository) + private notesRepository: NotesRepository, + @Inject(DI.noteReactionsRepository) private noteReactionsRepository: NoteReactionsRepository, @@ -69,16 +73,23 @@ export default class extends Endpoint { // eslint- throw new ApiError(meta.errors.reactionsNotPublic); } - const query = this.queryService.makePaginationQuery(this.noteReactionsRepository.createQueryBuilder('reaction'), - ps.sinceId, ps.untilId, ps.sinceDate, ps.untilDate) - .andWhere('reaction.userId = :userId', { userId: ps.userId }) - .leftJoinAndSelect('reaction.note', 'note'); + const query = this.notesRepository.createQueryBuilder('note') + .innerJoinAndSelect(qb => + this.queryService.makePaginationQuery( + qb + .from(this.noteReactionsRepository.metadata.targetName, 'reaction') + .where('"reaction"."userId" = :userId', { userId: ps.userId }), + ps.sinceId, ps.untilId, ps.sinceDate, ps.untilDate + ), + 'reaction', + '"reaction"."noteId" = note.id' + ); this.queryService.generateVisibilityQuery(query, me); const reactions = await query .limit(ps.limit) - .getMany(); + .getRawMany(); return await this.noteReactionEntityService.packMany(reactions, me, { withNote: true }); });