feat: 凍結されたユーザーのコンテンツを見えないようにする (MisskeyIO#134)
ついでにEntityServiceの型定義、meのoptionalをやめる
This commit is contained in:
@@ -3,7 +3,6 @@ import { DI } from '@/di-symbols.js';
|
||||
import type { RenoteMutingsRepository } from '@/models/index.js';
|
||||
import { awaitAll } from '@/misc/prelude/await-all.js';
|
||||
import type { Packed } from '@/misc/json-schema.js';
|
||||
import type { } from '@/models/entities/Blocking.js';
|
||||
import type { User } from '@/models/entities/User.js';
|
||||
import type { RenoteMuting } from '@/models/entities/RenoteMuting.js';
|
||||
import { bindThis } from '@/decorators.js';
|
||||
@@ -22,7 +21,7 @@ export class RenoteMutingEntityService {
|
||||
@bindThis
|
||||
public async pack(
|
||||
src: RenoteMuting['id'] | RenoteMuting,
|
||||
me?: { id: User['id'] } | null | undefined,
|
||||
me: { id: User['id'] } | null | undefined,
|
||||
): Promise<Packed<'RenoteMuting'>> {
|
||||
const muting = typeof src === 'object' ? src : await this.renoteMutingsRepository.findOneByOrFail({ id: src });
|
||||
|
||||
@@ -37,11 +36,12 @@ export class RenoteMutingEntityService {
|
||||
}
|
||||
|
||||
@bindThis
|
||||
public packMany(
|
||||
mutings: any[],
|
||||
me: { id: User['id'] },
|
||||
) {
|
||||
return Promise.all(mutings.map(x => this.pack(x, me)));
|
||||
public async packMany(
|
||||
mutings: (RenoteMuting['id'] | RenoteMuting)[],
|
||||
me: { id: User['id'] } | null | undefined,
|
||||
) : Promise<Packed<'RenoteMuting'>[]> {
|
||||
return (await Promise.allSettled(mutings.map(u => this.pack(u, me))))
|
||||
.filter(result => result.status === 'fulfilled')
|
||||
.map(result => (result as PromiseFulfilledResult<Packed<'RenoteMuting'>>).value);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user