summaryrefslogtreecommitdiff
path: root/packages/backend/src/server
diff options
context:
space:
mode:
authorsyuilo <4439005+syuilo@users.noreply.github.com>2025-06-28 21:38:54 +0900
committersyuilo <4439005+syuilo@users.noreply.github.com>2025-06-28 21:38:54 +0900
commit3c6f07fc8cccdcbbd1826ec42e34c423cf433105 (patch)
treeeab19a341585a5abb7b84c0eadffec85b10b5590 /packages/backend/src/server
parentenhance(frontend): improve modlog pagination (diff)
downloadmisskey-3c6f07fc8cccdcbbd1826ec42e34c423cf433105.tar.gz
misskey-3c6f07fc8cccdcbbd1826ec42e34c423cf433105.tar.bz2
misskey-3c6f07fc8cccdcbbd1826ec42e34c423cf433105.zip
feat: モデログを検索できるように
Diffstat (limited to 'packages/backend/src/server')
-rw-r--r--packages/backend/src/server/api/endpoints/admin/show-moderation-logs.ts17
1 files changed, 12 insertions, 5 deletions
diff --git a/packages/backend/src/server/api/endpoints/admin/show-moderation-logs.ts b/packages/backend/src/server/api/endpoints/admin/show-moderation-logs.ts
index e8ffd9cd9f..697fdf4210 100644
--- a/packages/backend/src/server/api/endpoints/admin/show-moderation-logs.ts
+++ b/packages/backend/src/server/api/endpoints/admin/show-moderation-logs.ts
@@ -9,6 +9,7 @@ import type { ModerationLogsRepository } from '@/models/_.js';
import { QueryService } from '@/core/QueryService.js';
import { DI } from '@/di-symbols.js';
import { ModerationLogEntityService } from '@/core/entities/ModerationLogEntityService.js';
+import { sqlLikeEscape } from '@/misc/sql-like-escape.js';
export const meta = {
tags: ['admin'],
@@ -67,6 +68,7 @@ export const paramDef = {
untilDate: { type: 'integer' },
type: { type: 'string', nullable: true },
userId: { type: 'string', format: 'misskey:id', nullable: true },
+ search: { type: 'string', nullable: true },
},
required: [],
} as const;
@@ -81,19 +83,24 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
private queryService: QueryService,
) {
super(meta, paramDef, async (ps, me) => {
- const query = this.queryService.makePaginationQuery(this.moderationLogsRepository.createQueryBuilder('report'), ps.sinceId, ps.untilId, ps.sinceDate, ps.untilDate);
+ const query = this.queryService.makePaginationQuery(this.moderationLogsRepository.createQueryBuilder('log'), ps.sinceId, ps.untilId, ps.sinceDate, ps.untilDate);
if (ps.type != null) {
- query.andWhere('report.type = :type', { type: ps.type });
+ query.andWhere('log.type = :type', { type: ps.type });
}
if (ps.userId != null) {
- query.andWhere('report.userId = :userId', { userId: ps.userId });
+ query.andWhere('log.userId = :userId', { userId: ps.userId });
}
- const reports = await query.limit(ps.limit).getMany();
+ if (ps.search != null) {
+ const escapedSearch = sqlLikeEscape(ps.search);
+ query.andWhere('log.info::text ILIKE :search', { search: `%${escapedSearch}%` });
+ }
+
+ const logs = await query.limit(ps.limit).getMany();
- return await this.moderationLogEntityService.packMany(reports);
+ return await this.moderationLogEntityService.packMany(logs);
});
}
}