diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c4134bdef0550491e4a2d2ef0fc151fe04fbadf..778e6cee1cd6a28bfbe3635061ff43d5e46c251f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -89,6 +89,7 @@ - Enhance: 自分ã¸ã®ãƒ¡ãƒ³ã‚·ãƒ§ãƒ³ä¸€è¦§ã‚’å–å¾—ã™ã‚‹éš›ã®ãƒ‘フォーマンスをå‘上 - Enhance: Docker環境ã§jemallocを使用ã™ã‚‹ã“ã¨ã§ãƒ¡ãƒ¢ãƒªä½¿ç”¨é‡ã‚’削減 - Fix: MK_ONLY_SERVERオプションを指定ã—ãŸéš›ã«ã‚¯ãƒ©ãƒƒã‚·ãƒ¥ã™ã‚‹å•é¡Œã‚’ä¿®æ£ +- Fix: notes/reactionsã®ãƒšãƒ¼ã‚¸ãƒãƒ¼ã‚·ãƒ§ãƒ³ãŒæ©Ÿèƒ½ã—ãªã„å•é¡Œã‚’ä¿®æ£ - Fix: ノート検索 `notes/search` ã«ã¦hostを指定ã—ãŸéš›ã«æ¤œç´¢çµæžœã«åæ˜ ã•ã‚Œã‚‹ã‚ˆã†ã« - Fix: 一部ã®featured noteを照会ã§ããªã„å•é¡Œã‚’ä¿®æ£ - Fix: muteãŒapiã‹ã‚‰ã®user list timelineå–å¾—ã§æ©Ÿèƒ½ã—ãªã„å•é¡Œã‚’ä¿®æ£ diff --git a/packages/backend/src/server/api/endpoints/notes/reactions.ts b/packages/backend/src/server/api/endpoints/notes/reactions.ts index dae31364ee2d4ea538248100f84ada6eba128e27..a2c17781993e8a9089ca542779eaa3bd9f494b7d 100644 --- a/packages/backend/src/server/api/endpoints/notes/reactions.ts +++ b/packages/backend/src/server/api/endpoints/notes/reactions.ts @@ -4,12 +4,13 @@ */ import { Inject, Injectable } from '@nestjs/common'; +import { Brackets, type FindOptionsWhere } from 'typeorm'; import type { NoteReactionsRepository } from '@/models/_.js'; import type { MiNoteReaction } from '@/models/NoteReaction.js'; import { Endpoint } from '@/server/api/endpoint-base.js'; import { NoteReactionEntityService } from '@/core/entities/NoteReactionEntityService.js'; import { DI } from '@/di-symbols.js'; -import type { FindOptionsWhere } from 'typeorm'; +import { QueryService } from '@/core/QueryService.js'; export const meta = { tags: ['notes', 'reactions'], @@ -44,7 +45,6 @@ export const paramDef = { noteId: { type: 'string', format: 'misskey:id' }, type: { type: 'string', nullable: true }, limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 }, - offset: { type: 'integer', default: 0 }, sinceId: { type: 'string', format: 'misskey:id' }, untilId: { type: 'string', format: 'misskey:id' }, }, @@ -58,29 +58,23 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint- private noteReactionsRepository: NoteReactionsRepository, private noteReactionEntityService: NoteReactionEntityService, + private queryService: QueryService, ) { super(meta, paramDef, async (ps, me) => { - const query = { - noteId: ps.noteId, - } as FindOptionsWhere<MiNoteReaction>; + const query = this.queryService.makePaginationQuery(this.noteReactionsRepository.createQueryBuilder('reaction'), ps.sinceId, ps.untilId) + .andWhere('reaction.noteId = :noteId', { noteId: ps.noteId }) + .leftJoinAndSelect('reaction.user', 'user') + .leftJoinAndSelect('reaction.note', 'note'); if (ps.type) { // ãƒãƒ¼ã‚«ãƒ«ãƒªã‚¢ã‚¯ã‚·ãƒ§ãƒ³ã¯ãƒ›ã‚¹ãƒˆå㌠. ã¨ã•ã‚Œã¦ã„る㌠// DB 上ã§ã¯ãã†ã§ã¯ãªã„ã®ã§ã€å¿…è¦ã«å¿œã˜ã¦å¤‰æ› const suffix = '@.:'; const type = ps.type.endsWith(suffix) ? ps.type.slice(0, ps.type.length - suffix.length) + ':' : ps.type; - query.reaction = type; + query.andWhere('reaction.reaction = :type', { type }); } - const reactions = await this.noteReactionsRepository.find({ - where: query, - take: ps.limit, - skip: ps.offset, - order: { - id: -1, - }, - relations: ['user', 'note'], - }); + const reactions = await query.limit(ps.limit).getMany(); return await Promise.all(reactions.map(reaction => this.noteReactionEntityService.pack(reaction, me))); });