feat(backend): クリップ内でノートを検索できるように

This commit is contained in:
syuilo 2025-06-29 15:10:51 +09:00
parent c215cccf1d
commit 8bc822d829
3 changed files with 14 additions and 0 deletions

View File

@ -2,6 +2,7 @@
### General
- Feat: ノートの下書き機能
- Feat: クリップ内でノートを検索できるように
### Client
- Feat: モデログを検索できるように

View File

@ -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<typeof meta, typeof paramDef> { // 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();

View File

@ -18274,6 +18274,7 @@ export interface operations {
untilId?: string;
sinceDate?: number;
untilDate?: number;
search?: string | null;
};
};
};