refactor: prefix Mi for all entities (misskey-dev#11719) (MisskeyIO#160)

cheery-pick from misskey-dev@792622aeadf3e36d50cddec3c64b2ff0105ea927
This commit is contained in:
まっちゃとーにゅ
2023-08-26 08:42:29 +09:00
committed by GitHub
parent 651905e08f
commit 58bbff3738
234 changed files with 2061 additions and 2061 deletions

View File

@@ -7,10 +7,10 @@ import { Inject, Injectable } from '@nestjs/common';
import { DI } from '@/di-symbols.js';
import type { AbuseUserReportsRepository } from '@/models/index.js';
import { awaitAll } from '@/misc/prelude/await-all.js';
import type { AbuseUserReport } from '@/models/entities/AbuseUserReport.js';
import type { MiAbuseUserReport } from '@/models/entities/AbuseUserReport.js';
import { bindThis } from '@/decorators.js';
import { Packed } from '@/misc/json-schema.js';
import type { User } from '@/models/entities/User.js';
import type { MiUser } from '@/models/entities/User.js';
import { UserEntityService } from './UserEntityService.js';
@Injectable()
@@ -25,8 +25,8 @@ export class AbuseUserReportEntityService {
@bindThis
public async pack(
src: AbuseUserReport['id'] | AbuseUserReport,
me: { id: User['id'] } | null | undefined,
src: MiAbuseUserReport['id'] | MiAbuseUserReport,
me: { id: MiUser['id'] } | null | undefined,
) : Promise<Packed<'AbuseUserReport'>> {
const report = typeof src === 'object' ? src : await this.abuseUserReportsRepository.findOneByOrFail({ id: src });
@@ -53,8 +53,8 @@ export class AbuseUserReportEntityService {
@bindThis
public async packMany(
reports: (AbuseUserReport['id'] | AbuseUserReport)[],
me: { id: User['id'] } | null | undefined,
reports: (MiAbuseUserReport['id'] | MiAbuseUserReport)[],
me: { id: MiUser['id'] } | null | undefined,
) : Promise<Packed<'AbuseUserReport'>[]> {
return (await Promise.allSettled(reports.map(x => this.pack(x, me))))
.filter(result => result.status === 'fulfilled')

View File

@@ -11,7 +11,7 @@ import type {
} from '@/models/index.js';
import type { Packed } from '@/misc/json-schema.js';
import { bindThis } from '@/decorators.js';
import { Announcement, User } from '@/models/index.js';
import { MiAnnouncement, MiUser } from '@/models/index.js';
@Injectable()
export class AnnouncementEntityService {
@@ -26,14 +26,14 @@ export class AnnouncementEntityService {
@bindThis
public async pack(
src: Announcement['id'] | Announcement & { isRead?: boolean | null },
me: { id: User['id'] } | null | undefined,
src: MiAnnouncement['id'] | MiAnnouncement & { isRead?: boolean | null },
me: { id: MiUser['id'] } | null | undefined,
): Promise<Packed<'Announcement'>> {
const announcement = typeof src === 'object'
? src
: await this.announcementsRepository.findOneByOrFail({
id: src,
}) as Announcement & { isRead?: boolean | null };
}) as MiAnnouncement & { isRead?: boolean | null };
if (me && announcement.isRead === undefined) {
announcement.isRead = await this.announcementReadsRepository.countBy({
@@ -61,8 +61,8 @@ export class AnnouncementEntityService {
@bindThis
public async packMany(
announcements: (Announcement['id'] | Announcement & { isRead?: boolean | null } | Announcement)[],
me: { id: User['id'] } | null | undefined,
announcements: (MiAnnouncement['id'] | MiAnnouncement & { isRead?: boolean | null } | MiAnnouncement)[],
me: { id: MiUser['id'] } | null | undefined,
) : Promise<Packed<'Announcement'>[]> {
return (await Promise.allSettled(announcements.map(x => this.pack(x, me))))
.filter(result => result.status === 'fulfilled')

View File

@@ -7,7 +7,7 @@ import { Inject, Injectable } from '@nestjs/common';
import { DI } from '@/di-symbols.js';
import type { AntennasRepository } from '@/models/index.js';
import type { Packed } from '@/misc/json-schema.js';
import type { Antenna } from '@/models/entities/Antenna.js';
import type { MiAntenna } from '@/models/entities/Antenna.js';
import { bindThis } from '@/decorators.js';
@Injectable()
@@ -20,7 +20,7 @@ export class AntennaEntityService {
@bindThis
public async pack(
src: Antenna['id'] | Antenna,
src: MiAntenna['id'] | MiAntenna,
): Promise<Packed<'Antenna'>> {
const antenna = typeof src === 'object' ? src : await this.antennasRepository.findOneByOrFail({ id: src });

View File

@@ -7,8 +7,8 @@ import { Inject, Injectable } from '@nestjs/common';
import { DI } from '@/di-symbols.js';
import type { AccessTokensRepository, AppsRepository } from '@/models/index.js';
import type { Packed } from '@/misc/json-schema.js';
import type { App } from '@/models/entities/App.js';
import type { User } from '@/models/entities/User.js';
import type { MiApp } from '@/models/entities/App.js';
import type { MiUser } from '@/models/entities/User.js';
import { bindThis } from '@/decorators.js';
@Injectable()
@@ -24,8 +24,8 @@ export class AppEntityService {
@bindThis
public async pack(
src: App['id'] | App,
me: { id: User['id'] } | null | undefined,
src: MiApp['id'] | MiApp,
me: { id: MiUser['id'] } | null | undefined,
options?: {
detail?: boolean,
includeSecret?: boolean,

View File

@@ -7,8 +7,8 @@ import { Inject, Injectable } from '@nestjs/common';
import { DI } from '@/di-symbols.js';
import type { AuthSessionsRepository } from '@/models/index.js';
import { awaitAll } from '@/misc/prelude/await-all.js';
import type { AuthSession } from '@/models/entities/AuthSession.js';
import type { User } from '@/models/entities/User.js';
import type { MiAuthSession } from '@/models/entities/AuthSession.js';
import type { MiUser } from '@/models/entities/User.js';
import { bindThis } from '@/decorators.js';
import { AppEntityService } from './AppEntityService.js';
@@ -24,8 +24,8 @@ export class AuthSessionEntityService {
@bindThis
public async pack(
src: AuthSession['id'] | AuthSession,
me: { id: User['id'] } | null | undefined,
src: MiAuthSession['id'] | MiAuthSession,
me: { id: MiUser['id'] } | null | undefined,
) {
const session = typeof src === 'object' ? src : await this.authSessionsRepository.findOneByOrFail({ id: src });

View File

@@ -8,8 +8,8 @@ import { DI } from '@/di-symbols.js';
import type { BlockingsRepository } from '@/models/index.js';
import { awaitAll } from '@/misc/prelude/await-all.js';
import type { Packed } from '@/misc/json-schema.js';
import type { Blocking } from '@/models/entities/Blocking.js';
import type { User } from '@/models/entities/User.js';
import type { MiBlocking } from '@/models/entities/Blocking.js';
import type { MiUser } from '@/models/entities/User.js';
import { bindThis } from '@/decorators.js';
import { UserEntityService } from './UserEntityService.js';
@@ -25,8 +25,8 @@ export class BlockingEntityService {
@bindThis
public async pack(
src: Blocking['id'] | Blocking,
me: { id: User['id'] } | null | undefined,
src: MiBlocking['id'] | MiBlocking,
me: { id: MiUser['id'] } | null | undefined,
): Promise<Packed<'Blocking'>> {
const blocking = typeof src === 'object' ? src : await this.blockingsRepository.findOneByOrFail({ id: src });
@@ -42,8 +42,8 @@ export class BlockingEntityService {
@bindThis
public async packMany(
blockings: (Blocking['id'] | Blocking)[],
me: { id: User['id'] } | null | undefined,
blockings: (MiBlocking['id'] | MiBlocking)[],
me: { id: MiUser['id'] } | null | undefined,
) : Promise<Packed<'Blocking'>[]> {
return (await Promise.allSettled(blockings.map(x => this.pack(x, me))))
.filter(result => result.status === 'fulfilled')

View File

@@ -15,8 +15,8 @@ import type {
NoteUnreadsRepository,
} from '@/models/index.js';
import type { Packed } from '@/misc/json-schema.js';
import type { User } from '@/models/entities/User.js';
import type { Channel } from '@/models/entities/Channel.js';
import type { MiUser } from '@/models/entities/User.js';
import type { MiChannel } from '@/models/entities/Channel.js';
import { bindThis } from '@/decorators.js';
import { DriveFileEntityService } from './DriveFileEntityService.js';
import { NoteEntityService } from './NoteEntityService.js';
@@ -49,8 +49,8 @@ export class ChannelEntityService {
@bindThis
public async pack(
src: Channel['id'] | Channel,
me: { id: User['id'] } | null | undefined,
src: MiChannel['id'] | MiChannel,
me: { id: MiUser['id'] } | null | undefined,
detailed?: boolean,
): Promise<Packed<'Channel'>> {
const channel = typeof src === 'object' ? src : await this.channelsRepository.findOneByOrFail({ id: src });

View File

@@ -5,10 +5,10 @@
import { Inject, Injectable } from '@nestjs/common';
import { DI } from '@/di-symbols.js';
import type { ClipFavoritesRepository, ClipsRepository, User } from '@/models/index.js';
import type { ClipFavoritesRepository, ClipsRepository, MiUser } from '@/models/index.js';
import { awaitAll } from '@/misc/prelude/await-all.js';
import type { Packed } from '@/misc/json-schema.js';
import type { Clip } from '@/models/entities/Clip.js';
import type { MiClip } from '@/models/entities/Clip.js';
import { bindThis } from '@/decorators.js';
import { UserEntityService } from './UserEntityService.js';
@@ -27,8 +27,8 @@ export class ClipEntityService {
@bindThis
public async pack(
src: Clip['id'] | Clip,
me: { id: User['id'] } | null | undefined,
src: MiClip['id'] | MiClip,
me: { id: MiUser['id'] } | null | undefined,
): Promise<Packed<'Clip'>> {
const meId = me ? me.id : null;
const clip = typeof src === 'object' ? src : await this.clipsRepository.findOneByOrFail({ id: src });
@@ -49,8 +49,8 @@ export class ClipEntityService {
@bindThis
public async packMany(
clips: (Clip['id'] | Clip)[],
me: { id: User['id'] } | null | undefined,
clips: (MiClip['id'] | MiClip)[],
me: { id: MiUser['id'] } | null | undefined,
) : Promise<Packed<'Clip'>[]> {
return (await Promise.allSettled(clips.map(x => this.pack(x, me))))
.filter(result => result.status === 'fulfilled')

View File

@@ -10,8 +10,8 @@ import type { DriveFilesRepository, NotesRepository } from '@/models/index.js';
import type { Config } from '@/config.js';
import type { Packed } from '@/misc/json-schema.js';
import { awaitAll } from '@/misc/prelude/await-all.js';
import type { User } from '@/models/entities/User.js';
import type { DriveFile } from '@/models/entities/DriveFile.js';
import type { MiUser } from '@/models/entities/User.js';
import type { MiDriveFile } from '@/models/entities/DriveFile.js';
import { appendQuery, query } from '@/misc/prelude/url.js';
import { deepClone } from '@/misc/clone.js';
import { bindThis } from '@/decorators.js';
@@ -65,7 +65,7 @@ export class DriveFileEntityService {
}
@bindThis
public getPublicProperties(file: DriveFile): DriveFile['properties'] {
public getPublicProperties(file: MiDriveFile): MiDriveFile['properties'] {
if (file.properties.orientation != null) {
const properties = deepClone(file.properties);
if (file.properties.orientation >= 5) {
@@ -90,7 +90,7 @@ export class DriveFileEntityService {
}
@bindThis
public getThumbnailUrl(file: DriveFile): string | null {
public getThumbnailUrl(file: MiDriveFile): string | null {
if (file.type.startsWith('video')) {
if (file.thumbnailUrl) return file.thumbnailUrl;
@@ -113,7 +113,7 @@ export class DriveFileEntityService {
}
@bindThis
public getPublicUrl(file: DriveFile, mode?: 'avatar'): string { // static = thumbnail
public getPublicUrl(file: MiDriveFile, mode?: 'avatar'): string { // static = thumbnail
// リモートかつメディアプロキシ
if (file.uri != null && file.userHost != null && this.config.externalMediaProxyEnabled) {
return this.getProxiedUrl(file.uri, mode);
@@ -139,7 +139,7 @@ export class DriveFileEntityService {
}
@bindThis
public async calcDriveUsageOf(user: User['id'] | { id: User['id'] }): Promise<number> {
public async calcDriveUsageOf(user: MiUser['id'] | { id: MiUser['id'] }): Promise<number> {
const id = typeof user === 'object' ? user.id : user;
const { sum } = await this.driveFilesRepository
@@ -190,8 +190,8 @@ export class DriveFileEntityService {
@bindThis
public async pack(
src: DriveFile['id'] | DriveFile,
me: { id: User['id'] } | null | undefined,
src: MiDriveFile['id'] | MiDriveFile,
me: { id: MiUser['id'] } | null | undefined,
options?: PackOptions,
): Promise<Packed<'DriveFile'>> {
const opts = Object.assign({
@@ -225,8 +225,8 @@ export class DriveFileEntityService {
@bindThis
public async packNullable(
src: DriveFile['id'] | DriveFile,
me: { id: User['id'] } | null | undefined,
src: MiDriveFile['id'] | MiDriveFile,
me: { id: MiUser['id'] } | null | undefined,
options?: PackOptions,
): Promise<Packed<'DriveFile'> | null> {
const opts = Object.assign({
@@ -261,8 +261,8 @@ export class DriveFileEntityService {
@bindThis
public async packMany(
files: DriveFile[],
me: { id: User['id'] } | null | undefined,
files: MiDriveFile[],
me: { id: MiUser['id'] } | null | undefined,
options?: PackOptions,
): Promise<Packed<'DriveFile'>[]> {
return (await Promise.allSettled(files.map(f => this.packNullable(f, me, options))))
@@ -272,8 +272,8 @@ export class DriveFileEntityService {
@bindThis
public async packManyByIdsMap(
fileIds: DriveFile['id'][],
me: { id: User['id'] } | null | undefined,
fileIds: MiDriveFile['id'][],
me: { id: MiUser['id'] } | null | undefined,
options?: PackOptions,
): Promise<Map<Packed<'DriveFile'>['id'], Packed<'DriveFile'> | null>> {
if (fileIds.length === 0) return new Map();
@@ -288,8 +288,8 @@ export class DriveFileEntityService {
@bindThis
public async packManyByIds(
fileIds: DriveFile['id'][],
me: { id: User['id'] } | null | undefined,
fileIds: MiDriveFile['id'][],
me: { id: MiUser['id'] } | null | undefined,
options?: PackOptions,
): Promise<Packed<'DriveFile'>[]> {
if (fileIds.length === 0) return [];

View File

@@ -8,7 +8,7 @@ import { DI } from '@/di-symbols.js';
import type { DriveFilesRepository, DriveFoldersRepository } from '@/models/index.js';
import { awaitAll } from '@/misc/prelude/await-all.js';
import type { Packed } from '@/misc/json-schema.js';
import type { DriveFolder } from '@/models/entities/DriveFolder.js';
import type { MiDriveFolder } from '@/models/entities/DriveFolder.js';
import { bindThis } from '@/decorators.js';
@Injectable()
@@ -24,7 +24,7 @@ export class DriveFolderEntityService {
@bindThis
public async pack(
src: DriveFolder['id'] | DriveFolder,
src: MiDriveFolder['id'] | MiDriveFolder,
options?: {
detail: boolean
},

View File

@@ -7,7 +7,7 @@ import { Inject, Injectable } from '@nestjs/common';
import { DI } from '@/di-symbols.js';
import type { EmojisRepository } from '@/models/index.js';
import type { Packed } from '@/misc/json-schema.js';
import type { Emoji } from '@/models/entities/Emoji.js';
import type { MiEmoji } from '@/models/entities/Emoji.js';
import { bindThis } from '@/decorators.js';
@Injectable()
@@ -20,7 +20,7 @@ export class EmojiEntityService {
@bindThis
public async packSimple(
src: Emoji['id'] | Emoji,
src: MiEmoji['id'] | MiEmoji,
): Promise<Packed<'EmojiSimple'>> {
const emoji = typeof src === 'object' ? src : await this.emojisRepository.findOneByOrFail({ id: src });
@@ -38,7 +38,7 @@ export class EmojiEntityService {
@bindThis
public async packSimpleMany(
emojis: (Emoji['id'] | Emoji)[],
emojis: (MiEmoji['id'] | MiEmoji)[],
) : Promise<Packed<'EmojiSimple'>[]> {
return (await Promise.allSettled(emojis.map(x => this.packSimple(x))))
.filter(result => result.status === 'fulfilled')
@@ -47,7 +47,7 @@ export class EmojiEntityService {
@bindThis
public async packDetailed(
src: Emoji['id'] | Emoji,
src: MiEmoji['id'] | MiEmoji,
): Promise<Packed<'EmojiDetailed'>> {
const emoji = typeof src === 'object' ? src : await this.emojisRepository.findOneByOrFail({ id: src });
@@ -69,7 +69,7 @@ export class EmojiEntityService {
@bindThis
public async packDetailedMany(
emojis: (Emoji['id'] | Emoji)[],
emojis: (MiEmoji['id'] | MiEmoji)[],
) : Promise<Packed<'EmojiDetailed'>[]> {
return (await Promise.allSettled(emojis.map(x => this.packDetailed(x))))
.filter(result => result.status === 'fulfilled')

View File

@@ -8,8 +8,8 @@ import { DI } from '@/di-symbols.js';
import type { FlashLikesRepository, FlashsRepository } from '@/models/index.js';
import { awaitAll } from '@/misc/prelude/await-all.js';
import type { Packed } from '@/misc/json-schema.js';
import type { User } from '@/models/entities/User.js';
import type { Flash } from '@/models/entities/Flash.js';
import type { MiUser } from '@/models/entities/User.js';
import type { MiFlash } from '@/models/entities/Flash.js';
import { bindThis } from '@/decorators.js';
import { UserEntityService } from './UserEntityService.js';
@@ -28,8 +28,8 @@ export class FlashEntityService {
@bindThis
public async pack(
src: Flash['id'] | Flash,
me: { id: User['id'] } | null | undefined,
src: MiFlash['id'] | MiFlash,
me: { id: MiUser['id'] } | null | undefined,
): Promise<Packed<'Flash'>> {
const meId = me ? me.id : null;
const flash = typeof src === 'object' ? src : await this.flashsRepository.findOneByOrFail({ id: src });
@@ -50,8 +50,8 @@ export class FlashEntityService {
@bindThis
public async packMany(
flashs: (Flash['id'] | Flash)[],
me: { id: User['id'] } | null | undefined,
flashs: (MiFlash['id'] | MiFlash)[],
me: { id: MiUser['id'] } | null | undefined,
) : Promise<Packed<'Flash'>[]> {
return (await Promise.allSettled(flashs.map(x => this.pack(x, me))))
.filter(result => result.status === 'fulfilled')

View File

@@ -6,8 +6,8 @@
import { Inject, Injectable } from '@nestjs/common';
import { DI } from '@/di-symbols.js';
import type { FlashLikesRepository } from '@/models/index.js';
import type { User } from '@/models/entities/User.js';
import type { FlashLike } from '@/models/entities/FlashLike.js';
import type { MiUser } from '@/models/entities/User.js';
import type { MiFlashLike } from '@/models/entities/FlashLike.js';
import { bindThis } from '@/decorators.js';
import { Packed } from '@/misc/json-schema.js';
import { FlashEntityService } from './FlashEntityService.js';
@@ -24,8 +24,8 @@ export class FlashLikeEntityService {
@bindThis
public async pack(
src: FlashLike['id'] | FlashLike,
me: { id: User['id'] } | null | undefined,
src: MiFlashLike['id'] | MiFlashLike,
me: { id: MiUser['id'] } | null | undefined,
) : Promise<Packed<'FlashLike'>> {
const like = typeof src === 'object' ? src : await this.flashLikesRepository.findOneByOrFail({ id: src });
@@ -37,8 +37,8 @@ export class FlashLikeEntityService {
@bindThis
public async packMany(
likes: (FlashLike['id'] | FlashLike)[],
me: { id: User['id'] } | null | undefined,
likes: (MiFlashLike['id'] | MiFlashLike)[],
me: { id: MiUser['id'] } | null | undefined,
) : Promise<Packed<'FlashLike'>[]> {
return (await Promise.allSettled(likes.map(x => this.pack(x, me))))
.filter(result => result.status === 'fulfilled')

View File

@@ -6,8 +6,8 @@
import { Inject, Injectable } from '@nestjs/common';
import { DI } from '@/di-symbols.js';
import type { FollowRequestsRepository } from '@/models/index.js';
import type { User } from '@/models/entities/User.js';
import type { FollowRequest } from '@/models/entities/FollowRequest.js';
import type { MiUser } from '@/models/entities/User.js';
import type { MiFollowRequest } from '@/models/entities/FollowRequest.js';
import { bindThis } from '@/decorators.js';
import { Packed } from '@/misc/json-schema.js';
import { UserEntityService } from './UserEntityService.js';
@@ -24,8 +24,8 @@ export class FollowRequestEntityService {
@bindThis
public async pack(
src: FollowRequest['id'] | FollowRequest,
me: { id: User['id'] } | null | undefined,
src: MiFollowRequest['id'] | MiFollowRequest,
me: { id: MiUser['id'] } | null | undefined,
) : Promise<Packed<'FollowRequest'>> {
const request = typeof src === 'object' ? src : await this.followRequestsRepository.findOneByOrFail({ id: src });
@@ -38,8 +38,8 @@ export class FollowRequestEntityService {
@bindThis
public async packMany(
requests: (FollowRequest['id'] | FollowRequest)[],
me: { id: User['id'] } | null | undefined,
requests: (MiFollowRequest['id'] | MiFollowRequest)[],
me: { id: MiUser['id'] } | null | undefined,
) : Promise<Packed<'FollowRequest'>[]> {
return (await Promise.allSettled(requests.map(x => this.pack(x, me))))
.filter(result => result.status === 'fulfilled')

View File

@@ -8,30 +8,30 @@ import { DI } from '@/di-symbols.js';
import type { FollowingsRepository } from '@/models/index.js';
import { awaitAll } from '@/misc/prelude/await-all.js';
import type { Packed } from '@/misc/json-schema.js';
import type { User } from '@/models/entities/User.js';
import type { Following } from '@/models/entities/Following.js';
import type { MiUser } from '@/models/entities/User.js';
import type { MiFollowing } from '@/models/entities/Following.js';
import { bindThis } from '@/decorators.js';
import { UserEntityService } from './UserEntityService.js';
type LocalFollowerFollowing = Following & {
type LocalFollowerFollowing = MiFollowing & {
followerHost: null;
followerInbox: null;
followerSharedInbox: null;
};
type RemoteFollowerFollowing = Following & {
type RemoteFollowerFollowing = MiFollowing & {
followerHost: string;
followerInbox: string;
followerSharedInbox: string;
};
type LocalFolloweeFollowing = Following & {
type LocalFolloweeFollowing = MiFollowing & {
followeeHost: null;
followeeInbox: null;
followeeSharedInbox: null;
};
type RemoteFolloweeFollowing = Following & {
type RemoteFolloweeFollowing = MiFollowing & {
followeeHost: string;
followeeInbox: string;
followeeSharedInbox: string;
@@ -48,29 +48,29 @@ export class FollowingEntityService {
}
@bindThis
public isLocalFollower(following: Following): following is LocalFollowerFollowing {
public isLocalFollower(following: MiFollowing): following is LocalFollowerFollowing {
return following.followerHost == null;
}
@bindThis
public isRemoteFollower(following: Following): following is RemoteFollowerFollowing {
public isRemoteFollower(following: MiFollowing): following is RemoteFollowerFollowing {
return following.followerHost != null;
}
@bindThis
public isLocalFollowee(following: Following): following is LocalFolloweeFollowing {
public isLocalFollowee(following: MiFollowing): following is LocalFolloweeFollowing {
return following.followeeHost == null;
}
@bindThis
public isRemoteFollowee(following: Following): following is RemoteFolloweeFollowing {
public isRemoteFollowee(following: MiFollowing): following is RemoteFolloweeFollowing {
return following.followeeHost != null;
}
@bindThis
public async pack(
src: Following['id'] | Following,
me: { id: User['id'] } | null | undefined,
src: MiFollowing['id'] | MiFollowing,
me: { id: MiUser['id'] } | null | undefined,
opts?: {
populateFollowee?: boolean;
populateFollower?: boolean;
@@ -96,8 +96,8 @@ export class FollowingEntityService {
@bindThis
public async packMany(
followings: (Following['id'] | Following)[],
me: { id: User['id'] } | null | undefined,
followings: (MiFollowing['id'] | MiFollowing)[],
me: { id: MiUser['id'] } | null | undefined,
opts?: {
populateFollowee?: boolean;
populateFollower?: boolean;

View File

@@ -6,10 +6,10 @@
import { Inject, Injectable } from '@nestjs/common';
import { DI } from '@/di-symbols.js';
import type { GalleryLikesRepository } from '@/models/index.js';
import type { GalleryLike } from '@/models/entities/GalleryLike.js';
import type { MiGalleryLike } from '@/models/entities/GalleryLike.js';
import { bindThis } from '@/decorators.js';
import { Packed } from '@/misc/json-schema.js';
import type { User } from '@/models/entities/User.js';
import type { MiUser } from '@/models/entities/User.js';
import { GalleryPostEntityService } from './GalleryPostEntityService.js';
@Injectable()
@@ -24,8 +24,8 @@ export class GalleryLikeEntityService {
@bindThis
public async pack(
src: GalleryLike['id'] | GalleryLike,
me: { id: User['id'] } | null | undefined,
src: MiGalleryLike['id'] | MiGalleryLike,
me: { id: MiUser['id'] } | null | undefined,
) : Promise<Packed<'GalleryLike'>> {
const like = typeof src === 'object' ? src : await this.galleryLikesRepository.findOneByOrFail({ id: src });
@@ -37,8 +37,8 @@ export class GalleryLikeEntityService {
@bindThis
public async packMany(
likes: (GalleryLike['id'] | GalleryLike)[],
me: { id: User['id'] } | null | undefined,
likes: (MiGalleryLike['id'] | MiGalleryLike)[],
me: { id: MiUser['id'] } | null | undefined,
) : Promise<Packed<'GalleryLike'>[]> {
return (await Promise.allSettled(likes.map(x => this.pack(x, me))))
.filter(result => result.status === 'fulfilled')

View File

@@ -8,8 +8,8 @@ import { DI } from '@/di-symbols.js';
import type { GalleryLikesRepository, GalleryPostsRepository } from '@/models/index.js';
import { awaitAll } from '@/misc/prelude/await-all.js';
import type { Packed } from '@/misc/json-schema.js';
import type { User } from '@/models/entities/User.js';
import type { GalleryPost } from '@/models/entities/GalleryPost.js';
import type { MiUser } from '@/models/entities/User.js';
import type { MiGalleryPost } from '@/models/entities/GalleryPost.js';
import { bindThis } from '@/decorators.js';
import { UserEntityService } from './UserEntityService.js';
import { DriveFileEntityService } from './DriveFileEntityService.js';
@@ -30,8 +30,8 @@ export class GalleryPostEntityService {
@bindThis
public async pack(
src: GalleryPost['id'] | GalleryPost,
me: { id: User['id'] } | null | undefined,
src: MiGalleryPost['id'] | MiGalleryPost,
me: { id: MiUser['id'] } | null | undefined,
): Promise<Packed<'GalleryPost'>> {
const meId = me ? me.id : null;
const post = typeof src === 'object' ? src : await this.galleryPostsRepository.findOneByOrFail({ id: src });
@@ -56,8 +56,8 @@ export class GalleryPostEntityService {
@bindThis
public async packMany(
posts: (GalleryPost['id'] | GalleryPost)[],
me: { id: User['id'] } | null | undefined,
posts: (MiGalleryPost['id'] | MiGalleryPost)[],
me: { id: MiUser['id'] } | null | undefined,
) : Promise<Packed<'GalleryPost'>[]> {
return (await Promise.allSettled(posts.map(x => this.pack(x, me))))
.filter(result => result.status === 'fulfilled')

View File

@@ -7,7 +7,7 @@ import { Inject, Injectable } from '@nestjs/common';
import { DI } from '@/di-symbols.js';
import type { HashtagsRepository } from '@/models/index.js';
import type { Packed } from '@/misc/json-schema.js';
import type { Hashtag } from '@/models/entities/Hashtag.js';
import type { MiHashtag } from '@/models/entities/Hashtag.js';
import { bindThis } from '@/decorators.js';
import { UserEntityService } from './UserEntityService.js';
@@ -23,7 +23,7 @@ export class HashtagEntityService {
@bindThis
public async pack(
src: Hashtag,
src: MiHashtag,
): Promise<Packed<'Hashtag'>> {
return {
tag: src.name,
@@ -38,7 +38,7 @@ export class HashtagEntityService {
@bindThis
public async packMany(
hashtags: Hashtag[],
hashtags: MiHashtag[],
) : Promise<Packed<'Hashtag'>[]> {
return (await Promise.allSettled(hashtags.map(x => this.pack(x))))
.filter(result => result.status === 'fulfilled')

View File

@@ -7,7 +7,7 @@ import { Inject, Injectable } from '@nestjs/common';
import { DI } from '@/di-symbols.js';
import type { InstancesRepository } from '@/models/index.js';
import type { Packed } from '@/misc/json-schema.js';
import type { Instance } from '@/models/entities/Instance.js';
import type { MiInstance } from '@/models/entities/Instance.js';
import { MetaService } from '@/core/MetaService.js';
import { bindThis } from '@/decorators.js';
import { UtilityService } from '../UtilityService.js';
@@ -26,7 +26,7 @@ export class InstanceEntityService {
@bindThis
public async pack(
instance: Instance,
instance: MiInstance,
): Promise<Packed<'FederationInstance'>> {
const meta = await this.metaService.fetch();
return {
@@ -56,7 +56,7 @@ export class InstanceEntityService {
@bindThis
public async packMany(
instances: Instance[],
instances: MiInstance[],
) : Promise<Packed<'FederationInstance'>[]> {
return (await Promise.allSettled(instances.map(x => this.pack(x))))
.filter(result => result.status === 'fulfilled')

View File

@@ -8,8 +8,8 @@ import { DI } from '@/di-symbols.js';
import type { RegistrationTicketsRepository } from '@/models/index.js';
import { awaitAll } from '@/misc/prelude/await-all.js';
import type { Packed } from '@/misc/json-schema.js';
import type { User } from '@/models/entities/User.js';
import type { RegistrationTicket } from '@/models/entities/RegistrationTicket.js';
import type { MiUser } from '@/models/entities/User.js';
import type { MiRegistrationTicket } from '@/models/entities/RegistrationTicket.js';
import { bindThis } from '@/decorators.js';
import { UserEntityService } from './UserEntityService.js';
@@ -25,8 +25,8 @@ export class InviteCodeEntityService {
@bindThis
public async pack(
src: RegistrationTicket['id'] | RegistrationTicket,
me: { id: User['id'] } | null | undefined,
src: MiRegistrationTicket['id'] | MiRegistrationTicket,
me: { id: MiUser['id'] } | null | undefined,
): Promise<Packed<'InviteCode'>> {
const target = typeof src === 'object' ? src : await this.registrationTicketsRepository.findOneOrFail({
where: {
@@ -49,8 +49,8 @@ export class InviteCodeEntityService {
@bindThis
public async packMany(
targets: (RegistrationTicket['id'] | RegistrationTicket)[],
me: { id: User['id'] } | null | undefined,
targets: (MiRegistrationTicket['id'] | MiRegistrationTicket)[],
me: { id: MiUser['id'] } | null | undefined,
) : Promise<Packed<'InviteCode'>[]> {
return (await Promise.allSettled(targets.map(x => this.pack(x, me))))
.filter(result => result.status === 'fulfilled')

View File

@@ -7,8 +7,8 @@ import { Inject, Injectable } from '@nestjs/common';
import { DI } from '@/di-symbols.js';
import type { ModerationLogsRepository } from '@/models/index.js';
import { awaitAll } from '@/misc/prelude/await-all.js';
import type { User } from '@/models/entities/User.js';
import type { ModerationLog } from '@/models/entities/ModerationLog.js';
import type { MiUser } from '@/models/entities/User.js';
import type { MiModerationLog } from '@/models/entities/ModerationLog.js';
import { bindThis } from '@/decorators.js';
import { Packed } from '@/misc/json-schema.js';
import { UserEntityService } from './UserEntityService.js';
@@ -25,8 +25,8 @@ export class ModerationLogEntityService {
@bindThis
public async pack(
src: ModerationLog['id'] | ModerationLog,
me: { id: User['id'] } | null | undefined,
src: MiModerationLog['id'] | MiModerationLog,
me: { id: MiUser['id'] } | null | undefined,
) : Promise<Packed<'ModerationLog'>> {
const log = typeof src === 'object' ? src : await this.moderationLogsRepository.findOneByOrFail({ id: src });
@@ -44,8 +44,8 @@ export class ModerationLogEntityService {
@bindThis
public async packMany(
reports: (ModerationLog['id'] | ModerationLog)[],
me: { id: User['id'] } | null | undefined,
reports: (MiModerationLog['id'] | MiModerationLog)[],
me: { id: MiUser['id'] } | null | undefined,
) : Promise<Packed<'ModerationLog'>[]> {
return (await Promise.allSettled(reports.map(x => this.pack(x, me))))
.filter(result => result.status === 'fulfilled')

View File

@@ -8,8 +8,8 @@ import { DI } from '@/di-symbols.js';
import type { MutingsRepository } from '@/models/index.js';
import { awaitAll } from '@/misc/prelude/await-all.js';
import type { Packed } from '@/misc/json-schema.js';
import type { User } from '@/models/entities/User.js';
import type { Muting } from '@/models/entities/Muting.js';
import type { MiUser } from '@/models/entities/User.js';
import type { MiMuting } from '@/models/entities/Muting.js';
import { bindThis } from '@/decorators.js';
import { UserEntityService } from './UserEntityService.js';
@@ -25,8 +25,8 @@ export class MutingEntityService {
@bindThis
public async pack(
src: Muting['id'] | Muting,
me: { id: User['id'] } | null | undefined,
src: MiMuting['id'] | MiMuting,
me: { id: MiUser['id'] } | null | undefined,
): Promise<Packed<'Muting'>> {
const muting = typeof src === 'object' ? src : await this.mutingsRepository.findOneByOrFail({ id: src });
@@ -43,8 +43,8 @@ export class MutingEntityService {
@bindThis
public async packMany(
mutings: (Muting['id'] | Muting)[],
me: { id: User['id'] } | null | undefined,
mutings: (MiMuting['id'] | MiMuting)[],
me: { id: MiUser['id'] } | null | undefined,
) : Promise<Packed<'Muting'>[]> {
return (await Promise.allSettled(mutings.map(x => this.pack(x, me))))
.filter(result => result.status === 'fulfilled')

View File

@@ -11,9 +11,9 @@ import { DI } from '@/di-symbols.js';
import type { Packed } from '@/misc/json-schema.js';
import { nyaize } from '@/misc/nyaize.js';
import { awaitAll } from '@/misc/prelude/await-all.js';
import type { User } from '@/models/entities/User.js';
import type { Note } from '@/models/entities/Note.js';
import type { NoteReaction } from '@/models/entities/NoteReaction.js';
import type { MiUser } from '@/models/entities/User.js';
import type { MiNote } from '@/models/entities/Note.js';
import type { MiNoteReaction } from '@/models/entities/NoteReaction.js';
import type {
ChannelsRepository,
DriveFilesRepository,
@@ -84,7 +84,7 @@ export class NoteEntityService implements OnModuleInit {
}
@bindThis
private async hideNote(packedNote: Packed<'Note'>, meId: User['id'] | null) {
private async hideNote(packedNote: Packed<'Note'>, meId: MiUser['id'] | null) {
// TODO: isVisibleForMe を使うようにしても良さそう(型違うけど)
let hide = false;
@@ -143,7 +143,7 @@ export class NoteEntityService implements OnModuleInit {
}
@bindThis
private async populatePoll(note: Note, meId: User['id'] | null) {
private async populatePoll(note: MiNote, meId: MiUser['id'] | null) {
const poll = await this.pollsRepository.findOneByOrFail({ noteId: note.id });
const choices = poll.choices.map(c => ({
text: c,
@@ -182,8 +182,8 @@ export class NoteEntityService implements OnModuleInit {
}
@bindThis
private async populateMyReaction(note: Note, meId: User['id'], _hint_?: {
myReactions: Map<Note['id'], NoteReaction | null>;
private async populateMyReaction(note: MiNote, meId: MiUser['id'], _hint_?: {
myReactions: Map<MiNote['id'], MiNoteReaction | null>;
}) {
if (_hint_?.myReactions) {
const reaction = _hint_.myReactions.get(note.id);
@@ -213,7 +213,7 @@ export class NoteEntityService implements OnModuleInit {
}
@bindThis
public async isVisibleForMe(note: Note, meId: User['id'] | null): Promise<boolean> {
public async isVisibleForMe(note: MiNote, meId: MiUser['id'] | null): Promise<boolean> {
// This code must always be synchronized with the checks in generateVisibilityQuery.
// visibility が specified かつ自分が指定されていなかったら非表示
if (note.visibility === 'specified') {
@@ -268,9 +268,9 @@ export class NoteEntityService implements OnModuleInit {
@bindThis
public async packAttachedFiles(
fileIds: Note['fileIds'],
packedFiles: Map<Note['fileIds'][number], Packed<'DriveFile'> | null>,
me: { id: User['id'] } | null | undefined,
fileIds: MiNote['fileIds'],
packedFiles: Map<MiNote['fileIds'][number], Packed<'DriveFile'> | null>,
me: { id: MiUser['id'] } | null | undefined,
): Promise<Packed<'DriveFile'>[]> {
const missingIds = [];
for (const id of fileIds) {
@@ -287,14 +287,14 @@ export class NoteEntityService implements OnModuleInit {
@bindThis
public async pack(
src: Note['id'] | Note,
me: { id: User['id'] } | null | undefined,
src: MiNote['id'] | MiNote,
me: { id: MiUser['id'] } | null | undefined,
options?: {
detail?: boolean;
skipHide?: boolean;
_hint_?: {
myReactions: Map<Note['id'], NoteReaction | null>;
packedFiles: Map<Note['fileIds'][number], Packed<'DriveFile'> | null>;
myReactions: Map<MiNote['id'], MiNoteReaction | null>;
packedFiles: Map<MiNote['fileIds'][number], Packed<'DriveFile'> | null>;
};
},
): Promise<Packed<'Note'>> {
@@ -404,8 +404,8 @@ export class NoteEntityService implements OnModuleInit {
@bindThis
public async packMany(
notes: Note[],
me: { id: User['id'] } | null | undefined,
notes: MiNote[],
me: { id: MiUser['id'] } | null | undefined,
options?: {
detail?: boolean;
skipHide?: boolean;
@@ -414,7 +414,7 @@ export class NoteEntityService implements OnModuleInit {
if (notes.length === 0) return [];
const meId = me ? me.id : null;
const myReactionsMap = new Map<Note['id'], NoteReaction | null>();
const myReactionsMap = new Map<MiNote['id'], MiNoteReaction | null>();
if (meId) {
const renoteIds = notes.filter(n => n.renoteId != null).map(n => n.renoteId!);
// パフォーマンスのためートが作成されてから1秒以上経っていない場合はリアクションを取得しない
@@ -446,7 +446,7 @@ export class NoteEntityService implements OnModuleInit {
}
@bindThis
public aggregateNoteEmojis(notes: Note[]) {
public aggregateNoteEmojis(notes: MiNote[]) {
let emojis: { name: string | null; host: string | null; }[] = [];
for (const note of notes) {
emojis = emojis.concat(note.emojis

View File

@@ -6,8 +6,8 @@
import { Inject, Injectable } from '@nestjs/common';
import { DI } from '@/di-symbols.js';
import type { NoteFavoritesRepository } from '@/models/index.js';
import type { User } from '@/models/entities/User.js';
import type { NoteFavorite } from '@/models/entities/NoteFavorite.js';
import type { MiUser } from '@/models/entities/User.js';
import type { MiNoteFavorite } from '@/models/entities/NoteFavorite.js';
import { bindThis } from '@/decorators.js';
import { Packed } from '@/misc/json-schema.js';
import { NoteEntityService } from './NoteEntityService.js';
@@ -24,8 +24,8 @@ export class NoteFavoriteEntityService {
@bindThis
public async pack(
src: NoteFavorite['id'] | NoteFavorite,
me: { id: User['id'] } | null | undefined,
src: MiNoteFavorite['id'] | MiNoteFavorite,
me: { id: MiUser['id'] } | null | undefined,
) : Promise<Packed<'NoteFavorite'>> {
const favorite = typeof src === 'object' ? src : await this.noteFavoritesRepository.findOneByOrFail({ id: src });
@@ -39,8 +39,8 @@ export class NoteFavoriteEntityService {
@bindThis
public async packMany(
favorites: (NoteFavorite['id'] | NoteFavorite)[],
me: { id: User['id'] } | null | undefined,
favorites: (MiNoteFavorite['id'] | MiNoteFavorite)[],
me: { id: MiUser['id'] } | null | undefined,
) : Promise<Packed<'NoteFavorite'>[]> {
return (await Promise.allSettled(favorites.map(x => this.pack(x, me))))
.filter(result => result.status === 'fulfilled')

View File

@@ -9,8 +9,8 @@ import { DI } from '@/di-symbols.js';
import type { NoteReactionsRepository } from '@/models/index.js';
import type { Packed } from '@/misc/json-schema.js';
import { bindThis } from '@/decorators.js';
import type { User } from '@/models/entities/User.js';
import type { NoteReaction } from '@/models/entities/NoteReaction.js';
import type { MiUser } from '@/models/entities/User.js';
import type { MiNoteReaction } from '@/models/entities/NoteReaction.js';
import type { OnModuleInit } from '@nestjs/common';
import type { ReactionService } from '../ReactionService.js';
import type { UserEntityService } from './UserEntityService.js';
@@ -42,8 +42,8 @@ export class NoteReactionEntityService implements OnModuleInit {
@bindThis
public async pack(
src: NoteReaction['id'] | NoteReaction,
me: { id: User['id'] } | null | undefined,
src: MiNoteReaction['id'] | MiNoteReaction,
me: { id: MiUser['id'] } | null | undefined,
options?: {
withNote: boolean;
},

View File

@@ -15,13 +15,13 @@ import type {
UsersRepository,
} from '@/models/index.js';
import { awaitAll } from '@/misc/prelude/await-all.js';
import type { Notification } from '@/models/entities/Notification.js';
import type { Note } from '@/models/entities/Note.js';
import type { MiNotification } from '@/models/entities/Notification.js';
import type { MiNote } from '@/models/entities/Note.js';
import type { Packed } from '@/misc/json-schema.js';
import { bindThis } from '@/decorators.js';
import { isNotNull } from '@/misc/is-not-null.js';
import { notificationTypes } from '@/types.js';
import type { User } from '@/models/entities/User.js';
import type { MiUser } from '@/models/entities/User.js';
import type { OnModuleInit } from '@nestjs/common';
import type { CustomEmojiService } from '../CustomEmojiService.js';
import type { UserEntityService } from './UserEntityService.js';
@@ -67,15 +67,15 @@ export class NotificationEntityService implements OnModuleInit {
@bindThis
public async pack(
src: Notification,
meId: User['id'],
src: MiNotification,
meId: MiUser['id'],
// eslint-disable-next-line @typescript-eslint/ban-types
options: {
},
hint?: {
packedNotes: Map<Note['id'], Packed<'Note'>>;
packedUsers: Map<User['id'], Packed<'User'>>;
packedNotes: Map<MiNote['id'], Packed<'Note'>>;
packedUsers: Map<MiUser['id'], Packed<'User'>>;
},
): Promise<Packed<'Notification'>> {
const notification = src;
@@ -118,8 +118,8 @@ export class NotificationEntityService implements OnModuleInit {
@bindThis
public async packMany(
notifications: Notification[],
meId: User['id'],
notifications: MiNotification[],
meId: MiUser['id'],
): Promise<Packed<'Notification'>[]> {
if (notifications.length === 0) return [];

View File

@@ -8,9 +8,9 @@ import { DI } from '@/di-symbols.js';
import type { DriveFilesRepository, PageLikesRepository, PagesRepository } from '@/models/index.js';
import { awaitAll } from '@/misc/prelude/await-all.js';
import type { Packed } from '@/misc/json-schema.js';
import type { User } from '@/models/entities/User.js';
import type { Page } from '@/models/entities/Page.js';
import type { DriveFile } from '@/models/entities/DriveFile.js';
import type { MiUser } from '@/models/entities/User.js';
import type { MiPage } from '@/models/entities/Page.js';
import type { MiDriveFile } from '@/models/entities/DriveFile.js';
import { bindThis } from '@/decorators.js';
import { UserEntityService } from './UserEntityService.js';
import { DriveFileEntityService } from './DriveFileEntityService.js';
@@ -34,13 +34,13 @@ export class PageEntityService {
@bindThis
public async pack(
src: Page['id'] | Page,
me: { id: User['id'] } | null | undefined,
src: MiPage['id'] | MiPage,
me: { id: MiUser['id'] } | null | undefined,
): Promise<Packed<'Page'>> {
const meId = me ? me.id : null;
const page = typeof src === 'object' ? src : await this.pagesRepository.findOneByOrFail({ id: src });
const attachedFiles: Promise<DriveFile | null>[] = [];
const attachedFiles: Promise<MiDriveFile | null>[] = [];
const collectFile = (xs: any[]) => {
for (const x of xs) {
if (x.type === 'image') {
@@ -99,7 +99,7 @@ export class PageEntityService {
script: page.script,
eyeCatchingImageId: page.eyeCatchingImageId,
eyeCatchingImage: page.eyeCatchingImageId ? await this.driveFileEntityService.pack(page.eyeCatchingImageId, me) : null,
attachedFiles: this.driveFileEntityService.packMany((await Promise.all(attachedFiles)).filter((x): x is DriveFile => x != null), me),
attachedFiles: this.driveFileEntityService.packMany((await Promise.all(attachedFiles)).filter((x): x is MiDriveFile => x != null), me),
likedCount: page.likedCount,
isLiked: meId ? await this.pageLikesRepository.exist({ where: { pageId: page.id, userId: meId } }) : undefined,
});
@@ -107,8 +107,8 @@ export class PageEntityService {
@bindThis
public async packMany(
pages: (Page['id'] | Page)[],
me: { id: User['id'] } | null | undefined,
pages: (MiPage['id'] | MiPage)[],
me: { id: MiUser['id'] } | null | undefined,
) : Promise<Packed<'Page'>[]> {
return (await Promise.allSettled(pages.map(x => this.pack(x, me))))
.filter(result => result.status === 'fulfilled')

View File

@@ -6,8 +6,8 @@
import { Inject, Injectable } from '@nestjs/common';
import { DI } from '@/di-symbols.js';
import type { PageLikesRepository } from '@/models/index.js';
import type { User } from '@/models/entities/User.js';
import type { PageLike } from '@/models/entities/PageLike.js';
import type { MiUser } from '@/models/entities/User.js';
import type { MiPageLike } from '@/models/entities/PageLike.js';
import { bindThis } from '@/decorators.js';
import { Packed } from '@/misc/json-schema.js';
import { PageEntityService } from './PageEntityService.js';
@@ -24,8 +24,8 @@ export class PageLikeEntityService {
@bindThis
public async pack(
src: PageLike['id'] | PageLike,
me: { id: User['id'] } | null | undefined,
src: MiPageLike['id'] | MiPageLike,
me: { id: MiUser['id'] } | null | undefined,
) : Promise<Packed<'PageLike'>> {
const like = typeof src === 'object' ? src : await this.pageLikesRepository.findOneByOrFail({ id: src });
@@ -37,8 +37,8 @@ export class PageLikeEntityService {
@bindThis
public async packMany(
likes: (PageLike['id'] | PageLike)[],
me: { id: User['id'] } | null | undefined,
likes: (MiPageLike['id'] | MiPageLike)[],
me: { id: MiUser['id'] } | null | undefined,
) : Promise<Packed<'PageLike'>[]> {
return (await Promise.allSettled(likes.map(x => this.pack(x, me))))
.filter(result => result.status === 'fulfilled')

View File

@@ -8,8 +8,8 @@ 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 { User } from '@/models/entities/User.js';
import type { RenoteMuting } from '@/models/entities/RenoteMuting.js';
import type { MiUser } from '@/models/entities/User.js';
import type { MiRenoteMuting } from '@/models/entities/RenoteMuting.js';
import { bindThis } from '@/decorators.js';
import { UserEntityService } from './UserEntityService.js';
@@ -25,8 +25,8 @@ export class RenoteMutingEntityService {
@bindThis
public async pack(
src: RenoteMuting['id'] | RenoteMuting,
me: { id: User['id'] } | null | undefined,
src: MiRenoteMuting['id'] | MiRenoteMuting,
me: { id: MiUser['id'] } | null | undefined,
): Promise<Packed<'RenoteMuting'>> {
const muting = typeof src === 'object' ? src : await this.renoteMutingsRepository.findOneByOrFail({ id: src });
@@ -42,8 +42,8 @@ export class RenoteMutingEntityService {
@bindThis
public async packMany(
mutings: (RenoteMuting['id'] | RenoteMuting)[],
me: { id: User['id'] } | null | undefined,
mutings: (MiRenoteMuting['id'] | MiRenoteMuting)[],
me: { id: MiUser['id'] } | null | undefined,
) : Promise<Packed<'RenoteMuting'>[]> {
return (await Promise.allSettled(mutings.map(u => this.pack(u, me))))
.filter(result => result.status === 'fulfilled')

View File

@@ -8,8 +8,8 @@ import { Brackets } from 'typeorm';
import { DI } from '@/di-symbols.js';
import type { RoleAssignmentsRepository, RolesRepository } from '@/models/index.js';
import { awaitAll } from '@/misc/prelude/await-all.js';
import type { User } from '@/models/entities/User.js';
import type { Role } from '@/models/entities/Role.js';
import type { MiUser } from '@/models/entities/User.js';
import type { MiRole } from '@/models/entities/Role.js';
import { bindThis } from '@/decorators.js';
import { DEFAULT_POLICIES } from '@/core/RoleService.js';
import { Packed } from '@/misc/json-schema.js';
@@ -30,8 +30,8 @@ export class RoleEntityService {
@bindThis
public async pack(
src: Role['id'] | Role,
me: { id: User['id'] } | null | undefined,
src: MiRole['id'] | MiRole,
me: { id: MiUser['id'] } | null | undefined,
) : Promise<Packed<'Role'>> {
const role = typeof src === 'object' ? src : await this.rolesRepository.findOneByOrFail({ id: src });
@@ -76,8 +76,8 @@ export class RoleEntityService {
@bindThis
public async packMany(
roles: (Role['id'] | Role)[],
me: { id: User['id'] } | null | undefined,
roles: (MiRole['id'] | MiRole)[],
me: { id: MiUser['id'] } | null | undefined,
) : Promise<Packed<'Role'>[]> {
return (await Promise.allSettled(roles.map(x => this.pack(x, me))))
.filter(result => result.status === 'fulfilled')

View File

@@ -6,7 +6,7 @@
import { Inject, Injectable } from '@nestjs/common';
import { DI } from '@/di-symbols.js';
import type { SigninsRepository } from '@/models/index.js';
import type { Signin } from '@/models/entities/Signin.js';
import type { MiSignin } from '@/models/entities/Signin.js';
import { bindThis } from '@/decorators.js';
import { UserEntityService } from './UserEntityService.js';
@@ -22,7 +22,7 @@ export class SigninEntityService {
@bindThis
public async pack(
src: Signin,
src: MiSignin,
) {
return src;
}

View File

@@ -13,7 +13,7 @@ import type { Packed } from '@/misc/json-schema.js';
import type { Promiseable } from '@/misc/prelude/await-all.js';
import { awaitAll } from '@/misc/prelude/await-all.js';
import { USER_ACTIVE_THRESHOLD, USER_ONLINE_THRESHOLD } from '@/const.js';
import type { LocalUser, PartialLocalUser, PartialRemoteUser, RemoteUser, User } from '@/models/entities/User.js';
import type { MiLocalUser, MiPartialLocalUser, MiPartialRemoteUser, MiRemoteUser, MiUser } from '@/models/entities/User.js';
import {
birthdaySchema,
descriptionSchema,
@@ -37,7 +37,7 @@ import type {
RenoteMutingsRepository,
UserMemoRepository,
UserNotePiningsRepository,
UserProfile,
MiUserProfile,
UserProfilesRepository,
UserSecurityKeysRepository,
UsersRepository,
@@ -65,15 +65,15 @@ type IsMeAndIsUserDetailed<ExpectsMe extends boolean | null, Detailed extends bo
const Ajv = _Ajv.default;
const ajv = new Ajv();
function isLocalUser(user: User): user is LocalUser;
function isLocalUser<T extends { host: User['host'] }>(user: T): user is (T & { host: null; });
function isLocalUser(user: User | { host: User['host'] }): boolean {
function isLocalUser(user: MiUser): user is MiLocalUser;
function isLocalUser<T extends { host: MiUser['host'] }>(user: T): user is (T & { host: null; });
function isLocalUser(user: MiUser | { host: MiUser['host'] }): boolean {
return user.host == null;
}
function isRemoteUser(user: User): user is RemoteUser;
function isRemoteUser<T extends { host: User['host'] }>(user: T): user is (T & { host: string; });
function isRemoteUser(user: User | { host: User['host'] }): boolean {
function isRemoteUser(user: MiUser): user is MiRemoteUser;
function isRemoteUser<T extends { host: MiUser['host'] }>(user: T): user is (T & { host: string; });
function isRemoteUser(user: MiUser | { host: MiUser['host'] }): boolean {
return !isLocalUser(user);
}
@@ -181,7 +181,7 @@ export class UserEntityService implements OnModuleInit {
public isRemoteUser = isRemoteUser;
@bindThis
public async getRelation(me: User['id'], target: User['id']) {
public async getRelation(me: MiUser['id'], target: MiUser['id']) {
return awaitAll({
id: target,
isFollowing: this.followingsRepository.count({
@@ -244,7 +244,7 @@ export class UserEntityService implements OnModuleInit {
}
@bindThis
public async getHasUnreadAntenna(userId: User['id']): Promise<boolean> {
public async getHasUnreadAntenna(userId: MiUser['id']): Promise<boolean> {
/*
const myAntennas = (await this.antennaService.getAntennas()).filter(a => a.userId === userId);
@@ -261,7 +261,7 @@ export class UserEntityService implements OnModuleInit {
}
@bindThis
public async getHasUnreadNotification(userId: User['id']): Promise<boolean> {
public async getHasUnreadNotification(userId: MiUser['id']): Promise<boolean> {
const latestReadNotificationId = await this.redisClient.get(`latestReadNotification:${userId}`);
const latestNotificationIdsRes = await this.redisClient.xrevrange(
@@ -275,7 +275,7 @@ export class UserEntityService implements OnModuleInit {
}
@bindThis
public async getHasPendingReceivedFollowRequest(userId: User['id']): Promise<boolean> {
public async getHasPendingReceivedFollowRequest(userId: MiUser['id']): Promise<boolean> {
const count = await this.followRequestsRepository.countBy({
followeeId: userId,
});
@@ -284,7 +284,7 @@ export class UserEntityService implements OnModuleInit {
}
@bindThis
public getOnlineStatus(user: User): 'unknown' | 'online' | 'active' | 'offline' {
public getOnlineStatus(user: MiUser): 'unknown' | 'online' | 'active' | 'offline' {
if (user.hideOnlineStatus) return 'unknown';
if (user.lastActiveDate == null) return 'unknown';
const elapsed = Date.now() - user.lastActiveDate.getTime();
@@ -296,12 +296,12 @@ export class UserEntityService implements OnModuleInit {
}
@bindThis
public getIdenticonUrl(user: User): string {
public getIdenticonUrl(user: MiUser): string {
return `${this.config.url}/identicon/${user.username.toLowerCase()}@${user.host ?? this.config.host}`;
}
@bindThis
public getUserUri(user: LocalUser | PartialLocalUser | RemoteUser | PartialRemoteUser): string {
public getUserUri(user: MiLocalUser | MiPartialLocalUser | MiRemoteUser | MiPartialRemoteUser): string {
return this.isRemoteUser(user)
? user.uri : this.genLocalUserUri(user.id);
}
@@ -312,12 +312,12 @@ export class UserEntityService implements OnModuleInit {
}
public async pack<ExpectsMe extends boolean | null = null, D extends boolean = false>(
src: User['id'] | User,
me: { id: User['id'] } | null | undefined,
src: MiUser['id'] | MiUser,
me: { id: MiUser['id'] } | null | undefined,
options?: {
detail?: D,
includeSecrets?: boolean,
userProfile?: UserProfile,
userProfile?: MiUserProfile,
},
): Promise<IsMeAndIsUserDetailed<ExpectsMe, D>> {
const opts = Object.assign({
@@ -347,7 +347,7 @@ export class UserEntityService implements OnModuleInit {
const meId = me ? me.id : null;
const isMe = meId === user.id;
const iAmModerator = me ? await this.roleService.isModerator(me as User) : false;
const iAmModerator = me ? await this.roleService.isModerator(me as MiUser) : false;
if (user.isSuspended && !iAmModerator) throw new IdentifiableError('8ca4f428-b32e-4f83-ac43-406ed7cd0452', 'This user is suspended.');
const relation = meId && !isMe && opts.detail ? await this.getRelation(meId, user.id) : null;
@@ -531,8 +531,8 @@ export class UserEntityService implements OnModuleInit {
}
public async packMany<D extends boolean = false>(
users: (User['id'] | User)[],
me: { id: User['id'] } | null | undefined,
users: (MiUser['id'] | MiUser)[],
me: { id: MiUser['id'] } | null | undefined,
options?: {
detail?: D,
includeSecrets?: boolean,

View File

@@ -7,7 +7,7 @@ import { Inject, Injectable } from '@nestjs/common';
import { DI } from '@/di-symbols.js';
import type { UserListJoiningsRepository, UserListsRepository } from '@/models/index.js';
import type { Packed } from '@/misc/json-schema.js';
import type { UserList } from '@/models/entities/UserList.js';
import type { MiUserList } from '@/models/entities/UserList.js';
import { bindThis } from '@/decorators.js';
import { UserEntityService } from './UserEntityService.js';
@@ -26,7 +26,7 @@ export class UserListEntityService {
@bindThis
public async pack(
src: UserList['id'] | UserList,
src: MiUserList['id'] | MiUserList,
): Promise<Packed<'UserList'>> {
const userList = typeof src === 'object' ? src : await this.userListsRepository.findOneByOrFail({ id: src });