feat: 凍結されたユーザーのコンテンツを見えないようにする (MisskeyIO#134)
ついでにEntityServiceの型定義、meのoptionalをやめる
This commit is contained in:
@@ -7,6 +7,7 @@ import type { User } from '@/models/entities/User.js';
|
||||
import type { Role } from '@/models/entities/Role.js';
|
||||
import { bindThis } from '@/decorators.js';
|
||||
import { DEFAULT_POLICIES } from '@/core/RoleService.js';
|
||||
import { Packed } from '@/misc/json-schema.js';
|
||||
import { UserEntityService } from './UserEntityService.js';
|
||||
|
||||
@Injectable()
|
||||
@@ -25,8 +26,8 @@ export class RoleEntityService {
|
||||
@bindThis
|
||||
public async pack(
|
||||
src: Role['id'] | Role,
|
||||
me?: { id: User['id'] } | null | undefined,
|
||||
) {
|
||||
me: { id: User['id'] } | null | undefined,
|
||||
) : Promise<Packed<'Role'>> {
|
||||
const role = typeof src === 'object' ? src : await this.rolesRepository.findOneByOrFail({ id: src });
|
||||
|
||||
const assignedCount = await this.roleAssignmentsRepository.createQueryBuilder('assign')
|
||||
@@ -69,11 +70,12 @@ export class RoleEntityService {
|
||||
}
|
||||
|
||||
@bindThis
|
||||
public packMany(
|
||||
roles: any[],
|
||||
me: { id: User['id'] },
|
||||
) {
|
||||
return Promise.all(roles.map(x => this.pack(x, me)));
|
||||
public async packMany(
|
||||
roles: (Role['id'] | Role)[],
|
||||
me: { id: User['id'] } | null | undefined,
|
||||
) : Promise<Packed<'Role'>[]> {
|
||||
return (await Promise.allSettled(roles.map(x => this.pack(x, me))))
|
||||
.filter(result => result.status === 'fulfilled')
|
||||
.map(result => (result as PromiseFulfilledResult<Packed<'Role'>>).value);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user