From 8bc822d829b823ec53c5e16d180f1898755df6c3 Mon Sep 17 00:00:00 2001 From: syuilo <4439005+syuilo@users.noreply.github.com> Date: Sun, 29 Jun 2025 15:10:51 +0900 Subject: [PATCH] =?UTF-8?q?feat(backend):=20=E3=82=AF=E3=83=AA=E3=83=83?= =?UTF-8?q?=E3=83=97=E5=86=85=E3=81=A7=E3=83=8E=E3=83=BC=E3=83=88=E3=82=92?= =?UTF-8?q?=E6=A4=9C=E7=B4=A2=E3=81=A7=E3=81=8D=E3=82=8B=E3=82=88=E3=81=86?= =?UTF-8?q?=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + .../backend/src/server/api/endpoints/clips/notes.ts | 12 ++++++++++++ packages/misskey-js/src/autogen/types.ts | 1 + 3 files changed, 14 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ca1e1dc12c..5fcab48640 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ### General - Feat: ノートの下書き機能 +- Feat: クリップ内でノートを検索できるように ### Client - Feat: モデログを検索できるように diff --git a/packages/backend/src/server/api/endpoints/clips/notes.ts b/packages/backend/src/server/api/endpoints/clips/notes.ts index 19302b1f8d..ecd0afc386 100644 --- a/packages/backend/src/server/api/endpoints/clips/notes.ts +++ b/packages/backend/src/server/api/endpoints/clips/notes.ts @@ -4,11 +4,13 @@ */ import { Inject, Injectable } from '@nestjs/common'; +import { Brackets } from 'typeorm'; import { Endpoint } from '@/server/api/endpoint-base.js'; import type { NotesRepository, ClipsRepository, ClipNotesRepository } from '@/models/_.js'; import { QueryService } from '@/core/QueryService.js'; import { NoteEntityService } from '@/core/entities/NoteEntityService.js'; import { DI } from '@/di-symbols.js'; +import { sqlLikeEscape } from '@/misc/sql-like-escape.js'; import { ApiError } from '../../error.js'; export const meta = { @@ -46,6 +48,7 @@ export const paramDef = { untilId: { type: 'string', format: 'misskey:id' }, sinceDate: { type: 'integer' }, untilDate: { type: 'integer' }, + search: { type: 'string', minLength: 1, maxLength: 100, nullable: true }, }, required: ['clipId'], } as const; @@ -97,6 +100,15 @@ export default class extends Endpoint { // eslint- this.queryService.generateBlockedUserQueryForNotes(query, me, { noteColumn: 'renote' }); } + if (ps.search != null) { + for (const word of ps.search!.trim().split(' ')) { + query.andWhere(new Brackets(qb => { + qb.orWhere('note.text ILIKE :search', { search: `%${sqlLikeEscape(word)}%` }); + qb.orWhere('note.cw ILIKE :search', { search: `%${sqlLikeEscape(word)}%` }); + })); + } + } + const notes = await query .limit(ps.limit) .getMany(); diff --git a/packages/misskey-js/src/autogen/types.ts b/packages/misskey-js/src/autogen/types.ts index 84c86a1c0f..cf2ee58621 100644 --- a/packages/misskey-js/src/autogen/types.ts +++ b/packages/misskey-js/src/autogen/types.ts @@ -18274,6 +18274,7 @@ export interface operations { untilId?: string; sinceDate?: number; untilDate?: number; + search?: string | null; }; }; };