mirror of
https://github.com/sim1222/misskey.git
synced 2025-08-03 23:16:28 +09:00
enhance: make configurable to whether notes search available by role
Resolve #10318
This commit is contained in:
@ -6,6 +6,8 @@ import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
|
||||
import type { Config } from '@/config.js';
|
||||
import { DI } from '@/di-symbols.js';
|
||||
import { sqlLikeEscape } from '@/misc/sql-like-escape.js';
|
||||
import { RoleService } from '@/core/RoleService.js';
|
||||
import { ApiError } from '../../error.js';
|
||||
|
||||
export const meta = {
|
||||
tags: ['notes'],
|
||||
@ -23,6 +25,11 @@ export const meta = {
|
||||
},
|
||||
|
||||
errors: {
|
||||
unavailable: {
|
||||
message: 'Search of notes unavailable.',
|
||||
code: 'UNAVAILABLE',
|
||||
id: '0b44998d-77aa-4427-80d0-d2c9b8523011',
|
||||
},
|
||||
},
|
||||
} as const;
|
||||
|
||||
@ -59,8 +66,14 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
||||
|
||||
private noteEntityService: NoteEntityService,
|
||||
private queryService: QueryService,
|
||||
private roleService: RoleService,
|
||||
) {
|
||||
super(meta, paramDef, async (ps, me) => {
|
||||
const policies = await this.roleService.getUserPolicies(me ? me.id : null);
|
||||
if (!policies.canSearchNotes) {
|
||||
throw new ApiError(meta.errors.unavailable);
|
||||
}
|
||||
|
||||
const query = this.queryService.makePaginationQuery(this.notesRepository.createQueryBuilder('note'), ps.sinceId, ps.untilId);
|
||||
|
||||
if (ps.userId) {
|
||||
|
Reference in New Issue
Block a user