refactor: prefix Mi for all entities (#11719)
* wip
* wip
* wip
* wip
* Update RepositoryModule.ts
* wip
* wip
* wip
* Revert "wip"
This reverts commit c1c13b37d2
.
This commit is contained in:
@@ -7,7 +7,7 @@ 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 { UserEntityService } from './UserEntityService.js';
|
||||
|
||||
@@ -23,7 +23,7 @@ export class AbuseUserReportEntityService {
|
||||
|
||||
@bindThis
|
||||
public async pack(
|
||||
src: AbuseUserReport['id'] | AbuseUserReport,
|
||||
src: MiAbuseUserReport['id'] | MiAbuseUserReport,
|
||||
) {
|
||||
const report = typeof src === 'object' ? src : await this.abuseUserReportsRepository.findOneByOrFail({ id: src });
|
||||
|
||||
|
@@ -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 });
|
||||
|
||||
|
@@ -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,
|
||||
|
@@ -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 });
|
||||
|
||||
|
@@ -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 });
|
||||
|
||||
@@ -43,7 +43,7 @@ export class BlockingEntityService {
|
||||
@bindThis
|
||||
public packMany(
|
||||
blockings: any[],
|
||||
me: { id: User['id'] },
|
||||
me: { id: MiUser['id'] },
|
||||
) {
|
||||
return Promise.all(blockings.map(x => this.pack(x, me)));
|
||||
}
|
||||
|
@@ -8,8 +8,8 @@ import { DI } from '@/di-symbols.js';
|
||||
import type { ChannelFavoritesRepository, ChannelFollowingsRepository, ChannelsRepository, DriveFilesRepository, NoteUnreadsRepository, NotesRepository } from '@/models/index.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 { 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';
|
||||
@@ -43,8 +43,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 });
|
||||
|
@@ -5,11 +5,11 @@
|
||||
|
||||
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 { } from '@/models/entities/Blocking.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';
|
||||
|
||||
@@ -28,8 +28,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 });
|
||||
@@ -50,8 +50,8 @@ export class ClipEntityService {
|
||||
|
||||
@bindThis
|
||||
public packMany(
|
||||
clips: Clip[],
|
||||
me?: { id: User['id'] } | null | undefined,
|
||||
clips: MiClip[],
|
||||
me?: { id: MiUser['id'] } | null | undefined,
|
||||
) {
|
||||
return Promise.all(clips.map(x => this.pack(x, me)));
|
||||
}
|
||||
|
@@ -10,10 +10,13 @@ import type { DriveFilesRepository } 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';
|
||||
import { isMimeImage } from '@/misc/is-mime-image.js';
|
||||
import { isNotNull } from '@/misc/is-not-null.js';
|
||||
import { UtilityService } from '../UtilityService.js';
|
||||
import { VideoProcessingService } from '../VideoProcessingService.js';
|
||||
import { UserEntityService } from './UserEntityService.js';
|
||||
@@ -24,9 +27,6 @@ type PackOptions = {
|
||||
self?: boolean,
|
||||
withUser?: boolean,
|
||||
};
|
||||
import { bindThis } from '@/decorators.js';
|
||||
import { isMimeImage } from '@/misc/is-mime-image.js';
|
||||
import { isNotNull } from '@/misc/is-not-null.js';
|
||||
|
||||
@Injectable()
|
||||
export class DriveFileEntityService {
|
||||
@@ -59,7 +59,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) {
|
||||
@@ -84,7 +84,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;
|
||||
|
||||
@@ -107,7 +107,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);
|
||||
@@ -133,7 +133,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
|
||||
@@ -184,7 +184,7 @@ export class DriveFileEntityService {
|
||||
|
||||
@bindThis
|
||||
public async pack(
|
||||
src: DriveFile['id'] | DriveFile,
|
||||
src: MiDriveFile['id'] | MiDriveFile,
|
||||
options?: PackOptions,
|
||||
): Promise<Packed<'DriveFile'>> {
|
||||
const opts = Object.assign({
|
||||
@@ -218,7 +218,7 @@ export class DriveFileEntityService {
|
||||
|
||||
@bindThis
|
||||
public async packNullable(
|
||||
src: DriveFile['id'] | DriveFile,
|
||||
src: MiDriveFile['id'] | MiDriveFile,
|
||||
options?: PackOptions,
|
||||
): Promise<Packed<'DriveFile'> | null> {
|
||||
const opts = Object.assign({
|
||||
@@ -253,7 +253,7 @@ export class DriveFileEntityService {
|
||||
|
||||
@bindThis
|
||||
public async packMany(
|
||||
files: DriveFile[],
|
||||
files: MiDriveFile[],
|
||||
options?: PackOptions,
|
||||
): Promise<Packed<'DriveFile'>[]> {
|
||||
const items = await Promise.all(files.map(f => this.packNullable(f, options)));
|
||||
@@ -262,7 +262,7 @@ export class DriveFileEntityService {
|
||||
|
||||
@bindThis
|
||||
public async packManyByIdsMap(
|
||||
fileIds: DriveFile['id'][],
|
||||
fileIds: MiDriveFile['id'][],
|
||||
options?: PackOptions,
|
||||
): Promise<Map<Packed<'DriveFile'>['id'], Packed<'DriveFile'> | null>> {
|
||||
if (fileIds.length === 0) return new Map();
|
||||
@@ -277,7 +277,7 @@ export class DriveFileEntityService {
|
||||
|
||||
@bindThis
|
||||
public async packManyByIds(
|
||||
fileIds: DriveFile['id'][],
|
||||
fileIds: MiDriveFile['id'][],
|
||||
options?: PackOptions,
|
||||
): Promise<Packed<'DriveFile'>[]> {
|
||||
if (fileIds.length === 0) return [];
|
||||
|
@@ -9,7 +9,7 @@ import type { DriveFilesRepository, DriveFoldersRepository } from '@/models/inde
|
||||
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 { DriveFolder } from '@/models/entities/DriveFolder.js';
|
||||
import type { MiDriveFolder } from '@/models/entities/DriveFolder.js';
|
||||
import { bindThis } from '@/decorators.js';
|
||||
|
||||
@Injectable()
|
||||
@@ -25,7 +25,7 @@ export class DriveFolderEntityService {
|
||||
|
||||
@bindThis
|
||||
public async pack(
|
||||
src: DriveFolder['id'] | DriveFolder,
|
||||
src: MiDriveFolder['id'] | MiDriveFolder,
|
||||
options?: {
|
||||
detail: boolean
|
||||
},
|
||||
|
@@ -8,7 +8,7 @@ import { DI } from '@/di-symbols.js';
|
||||
import type { EmojisRepository } from '@/models/index.js';
|
||||
import type { Packed } from '@/misc/json-schema.js';
|
||||
import type { } from '@/models/entities/Blocking.js';
|
||||
import type { Emoji } from '@/models/entities/Emoji.js';
|
||||
import type { MiEmoji } from '@/models/entities/Emoji.js';
|
||||
import { bindThis } from '@/decorators.js';
|
||||
|
||||
@Injectable()
|
||||
@@ -21,7 +21,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 });
|
||||
|
||||
@@ -45,7 +45,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 });
|
||||
|
||||
|
@@ -9,8 +9,8 @@ import type { FlashsRepository, FlashLikesRepository } 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 { 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';
|
||||
|
||||
@@ -29,8 +29,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 });
|
||||
@@ -51,8 +51,8 @@ export class FlashEntityService {
|
||||
|
||||
@bindThis
|
||||
public packMany(
|
||||
flashs: Flash[],
|
||||
me?: { id: User['id'] } | null | undefined,
|
||||
flashs: MiFlash[],
|
||||
me?: { id: MiUser['id'] } | null | undefined,
|
||||
) {
|
||||
return Promise.all(flashs.map(x => this.pack(x, me)));
|
||||
}
|
||||
|
@@ -7,8 +7,8 @@ import { Inject, Injectable } from '@nestjs/common';
|
||||
import { DI } from '@/di-symbols.js';
|
||||
import type { FlashLikesRepository } from '@/models/index.js';
|
||||
import type { } from '@/models/entities/Blocking.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 { 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,
|
||||
) {
|
||||
const like = typeof src === 'object' ? src : await this.flashLikesRepository.findOneByOrFail({ id: src });
|
||||
|
||||
@@ -38,7 +38,7 @@ export class FlashLikeEntityService {
|
||||
@bindThis
|
||||
public packMany(
|
||||
likes: any[],
|
||||
me: { id: User['id'] },
|
||||
me: { id: MiUser['id'] },
|
||||
) {
|
||||
return Promise.all(likes.map(x => this.pack(x, me)));
|
||||
}
|
||||
|
@@ -7,8 +7,8 @@ import { Inject, Injectable } from '@nestjs/common';
|
||||
import { DI } from '@/di-symbols.js';
|
||||
import type { FollowRequestsRepository } from '@/models/index.js';
|
||||
import type { } from '@/models/entities/Blocking.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 { 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,
|
||||
) {
|
||||
const request = typeof src === 'object' ? src : await this.followRequestsRepository.findOneByOrFail({ id: src });
|
||||
|
||||
|
@@ -9,30 +9,30 @@ 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 { } from '@/models/entities/Blocking.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;
|
||||
@@ -49,29 +49,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;
|
||||
@@ -98,7 +98,7 @@ export class FollowingEntityService {
|
||||
@bindThis
|
||||
public packMany(
|
||||
followings: any[],
|
||||
me?: { id: User['id'] } | null | undefined,
|
||||
me?: { id: MiUser['id'] } | null | undefined,
|
||||
opts?: {
|
||||
populateFollowee?: boolean;
|
||||
populateFollower?: boolean;
|
||||
|
@@ -7,7 +7,7 @@ import { Inject, Injectable } from '@nestjs/common';
|
||||
import { DI } from '@/di-symbols.js';
|
||||
import type { GalleryLikesRepository } from '@/models/index.js';
|
||||
import type { } from '@/models/entities/Blocking.js';
|
||||
import type { GalleryLike } from '@/models/entities/GalleryLike.js';
|
||||
import type { MiGalleryLike } from '@/models/entities/GalleryLike.js';
|
||||
import { bindThis } from '@/decorators.js';
|
||||
import { GalleryPostEntityService } from './GalleryPostEntityService.js';
|
||||
|
||||
@@ -23,7 +23,7 @@ export class GalleryLikeEntityService {
|
||||
|
||||
@bindThis
|
||||
public async pack(
|
||||
src: GalleryLike['id'] | GalleryLike,
|
||||
src: MiGalleryLike['id'] | MiGalleryLike,
|
||||
me?: any,
|
||||
) {
|
||||
const like = typeof src === 'object' ? src : await this.galleryLikesRepository.findOneByOrFail({ id: src });
|
||||
|
@@ -9,8 +9,8 @@ import type { GalleryLikesRepository, GalleryPostsRepository } from '@/models/in
|
||||
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 { 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';
|
||||
@@ -31,8 +31,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 });
|
||||
@@ -57,8 +57,8 @@ export class GalleryPostEntityService {
|
||||
|
||||
@bindThis
|
||||
public packMany(
|
||||
posts: GalleryPost[],
|
||||
me?: { id: User['id'] } | null | undefined,
|
||||
posts: MiGalleryPost[],
|
||||
me?: { id: MiUser['id'] } | null | undefined,
|
||||
) {
|
||||
return Promise.all(posts.map(x => this.pack(x, me)));
|
||||
}
|
||||
|
@@ -6,7 +6,7 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import type { Packed } from '@/misc/json-schema.js';
|
||||
import type { } from '@/models/entities/Blocking.js';
|
||||
import type { Hashtag } from '@/models/entities/Hashtag.js';
|
||||
import type { MiHashtag } from '@/models/entities/Hashtag.js';
|
||||
import { bindThis } from '@/decorators.js';
|
||||
|
||||
@Injectable()
|
||||
@@ -17,7 +17,7 @@ export class HashtagEntityService {
|
||||
|
||||
@bindThis
|
||||
public async pack(
|
||||
src: Hashtag,
|
||||
src: MiHashtag,
|
||||
): Promise<Packed<'Hashtag'>> {
|
||||
return {
|
||||
tag: src.name,
|
||||
@@ -32,7 +32,7 @@ export class HashtagEntityService {
|
||||
|
||||
@bindThis
|
||||
public packMany(
|
||||
hashtags: Hashtag[],
|
||||
hashtags: MiHashtag[],
|
||||
) {
|
||||
return Promise.all(hashtags.map(x => this.pack(x)));
|
||||
}
|
||||
|
@@ -6,7 +6,7 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import type { Packed } from '@/misc/json-schema.js';
|
||||
import type { } from '@/models/entities/Blocking.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';
|
||||
@@ -22,7 +22,7 @@ export class InstanceEntityService {
|
||||
|
||||
@bindThis
|
||||
public async pack(
|
||||
instance: Instance,
|
||||
instance: MiInstance,
|
||||
): Promise<Packed<'FederationInstance'>> {
|
||||
const meta = await this.metaService.fetch();
|
||||
return {
|
||||
@@ -52,7 +52,7 @@ export class InstanceEntityService {
|
||||
|
||||
@bindThis
|
||||
public packMany(
|
||||
instances: Instance[],
|
||||
instances: MiInstance[],
|
||||
) {
|
||||
return Promise.all(instances.map(x => this.pack(x)));
|
||||
}
|
||||
|
@@ -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: {
|
||||
@@ -50,7 +50,7 @@ export class InviteCodeEntityService {
|
||||
@bindThis
|
||||
public packMany(
|
||||
targets: any[],
|
||||
me: { id: User['id'] },
|
||||
me: { id: MiUser['id'] },
|
||||
) {
|
||||
return Promise.all(targets.map(x => this.pack(x, me)));
|
||||
}
|
||||
|
@@ -8,7 +8,7 @@ import { DI } from '@/di-symbols.js';
|
||||
import type { ModerationLogsRepository } from '@/models/index.js';
|
||||
import { awaitAll } from '@/misc/prelude/await-all.js';
|
||||
import type { } from '@/models/entities/Blocking.js';
|
||||
import type { ModerationLog } from '@/models/entities/ModerationLog.js';
|
||||
import type { MiModerationLog } from '@/models/entities/ModerationLog.js';
|
||||
import { bindThis } from '@/decorators.js';
|
||||
import { UserEntityService } from './UserEntityService.js';
|
||||
|
||||
@@ -24,7 +24,7 @@ export class ModerationLogEntityService {
|
||||
|
||||
@bindThis
|
||||
public async pack(
|
||||
src: ModerationLog['id'] | ModerationLog,
|
||||
src: MiModerationLog['id'] | MiModerationLog,
|
||||
) {
|
||||
const log = typeof src === 'object' ? src : await this.moderationLogsRepository.findOneByOrFail({ id: src });
|
||||
|
||||
|
@@ -9,8 +9,8 @@ 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 { } from '@/models/entities/Blocking.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';
|
||||
|
||||
@@ -26,8 +26,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 });
|
||||
|
||||
@@ -45,7 +45,7 @@ export class MutingEntityService {
|
||||
@bindThis
|
||||
public packMany(
|
||||
mutings: any[],
|
||||
me: { id: User['id'] },
|
||||
me: { id: MiUser['id'] },
|
||||
) {
|
||||
return Promise.all(mutings.map(x => this.pack(x, me)));
|
||||
}
|
||||
|
@@ -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 { UsersRepository, NotesRepository, FollowingsRepository, PollsRepository, PollVotesRepository, NoteReactionsRepository, ChannelsRepository } from '@/models/index.js';
|
||||
import { bindThis } from '@/decorators.js';
|
||||
import { isNotNull } from '@/misc/is-not-null.js';
|
||||
@@ -69,7 +69,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;
|
||||
|
||||
@@ -128,7 +128,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,
|
||||
@@ -167,8 +167,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);
|
||||
@@ -198,7 +198,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') {
|
||||
@@ -252,7 +252,7 @@ export class NoteEntityService implements OnModuleInit {
|
||||
}
|
||||
|
||||
@bindThis
|
||||
public async packAttachedFiles(fileIds: Note['fileIds'], packedFiles: Map<Note['fileIds'][number], Packed<'DriveFile'> | null>): Promise<Packed<'DriveFile'>[]> {
|
||||
public async packAttachedFiles(fileIds: MiNote['fileIds'], packedFiles: Map<MiNote['fileIds'][number], Packed<'DriveFile'> | null>): Promise<Packed<'DriveFile'>[]> {
|
||||
const missingIds = [];
|
||||
for (const id of fileIds) {
|
||||
if (!packedFiles.has(id)) missingIds.push(id);
|
||||
@@ -268,14 +268,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'>> {
|
||||
@@ -386,8 +386,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;
|
||||
@@ -396,7 +396,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秒以上経っていない場合はリアクションを取得しない
|
||||
@@ -426,7 +426,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
|
||||
|
@@ -7,8 +7,8 @@ import { Inject, Injectable } from '@nestjs/common';
|
||||
import { DI } from '@/di-symbols.js';
|
||||
import type { NoteFavoritesRepository } from '@/models/index.js';
|
||||
import type { } from '@/models/entities/Blocking.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 { 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,
|
||||
) {
|
||||
const favorite = typeof src === 'object' ? src : await this.noteFavoritesRepository.findOneByOrFail({ id: src });
|
||||
|
||||
@@ -40,7 +40,7 @@ export class NoteFavoriteEntityService {
|
||||
@bindThis
|
||||
public packMany(
|
||||
favorites: any[],
|
||||
me: { id: User['id'] },
|
||||
me: { id: MiUser['id'] },
|
||||
) {
|
||||
return Promise.all(favorites.map(x => this.pack(x, me)));
|
||||
}
|
||||
|
@@ -10,8 +10,8 @@ import type { Packed } from '@/misc/json-schema.js';
|
||||
import { bindThis } from '@/decorators.js';
|
||||
import type { OnModuleInit } from '@nestjs/common';
|
||||
import type { } from '@/models/entities/Blocking.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 { ReactionService } from '../ReactionService.js';
|
||||
import type { UserEntityService } from './UserEntityService.js';
|
||||
import type { NoteEntityService } from './NoteEntityService.js';
|
||||
@@ -43,8 +43,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;
|
||||
},
|
||||
|
@@ -7,10 +7,10 @@ import { Inject, Injectable } from '@nestjs/common';
|
||||
import { ModuleRef } from '@nestjs/core';
|
||||
import { In } from 'typeorm';
|
||||
import { DI } from '@/di-symbols.js';
|
||||
import type { AccessTokensRepository, FollowRequestsRepository, NotesRepository, User, UsersRepository } from '@/models/index.js';
|
||||
import type { AccessTokensRepository, FollowRequestsRepository, NotesRepository, MiUser, 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';
|
||||
@@ -57,15 +57,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;
|
||||
@@ -108,8 +108,8 @@ export class NotificationEntityService implements OnModuleInit {
|
||||
|
||||
@bindThis
|
||||
public async packMany(
|
||||
notifications: Notification[],
|
||||
meId: User['id'],
|
||||
notifications: MiNotification[],
|
||||
meId: MiUser['id'],
|
||||
) {
|
||||
if (notifications.length === 0) return [];
|
||||
|
||||
|
@@ -9,9 +9,9 @@ import type { DriveFilesRepository, PagesRepository, PageLikesRepository } from
|
||||
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 { 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';
|
||||
@@ -35,13 +35,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') {
|
||||
@@ -100,7 +100,7 @@ export class PageEntityService {
|
||||
script: page.script,
|
||||
eyeCatchingImageId: page.eyeCatchingImageId,
|
||||
eyeCatchingImage: page.eyeCatchingImageId ? await this.driveFileEntityService.pack(page.eyeCatchingImageId) : null,
|
||||
attachedFiles: this.driveFileEntityService.packMany((await Promise.all(attachedFiles)).filter((x): x is DriveFile => x != null)),
|
||||
attachedFiles: this.driveFileEntityService.packMany((await Promise.all(attachedFiles)).filter((x): x is MiDriveFile => x != null)),
|
||||
likedCount: page.likedCount,
|
||||
isLiked: meId ? await this.pageLikesRepository.exist({ where: { pageId: page.id, userId: meId } }) : undefined,
|
||||
});
|
||||
@@ -108,8 +108,8 @@ export class PageEntityService {
|
||||
|
||||
@bindThis
|
||||
public packMany(
|
||||
pages: Page[],
|
||||
me?: { id: User['id'] } | null | undefined,
|
||||
pages: MiPage[],
|
||||
me?: { id: MiUser['id'] } | null | undefined,
|
||||
) {
|
||||
return Promise.all(pages.map(x => this.pack(x, me)));
|
||||
}
|
||||
|
@@ -7,8 +7,8 @@ import { Inject, Injectable } from '@nestjs/common';
|
||||
import { DI } from '@/di-symbols.js';
|
||||
import type { PageLikesRepository } from '@/models/index.js';
|
||||
import type { } from '@/models/entities/Blocking.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 { 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,
|
||||
) {
|
||||
const like = typeof src === 'object' ? src : await this.pageLikesRepository.findOneByOrFail({ id: src });
|
||||
|
||||
@@ -38,7 +38,7 @@ export class PageLikeEntityService {
|
||||
@bindThis
|
||||
public packMany(
|
||||
likes: any[],
|
||||
me: { id: User['id'] },
|
||||
me: { id: MiUser['id'] },
|
||||
) {
|
||||
return Promise.all(likes.map(x => this.pack(x, me)));
|
||||
}
|
||||
|
@@ -9,8 +9,8 @@ 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 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';
|
||||
|
||||
@@ -26,8 +26,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 });
|
||||
|
||||
@@ -44,7 +44,7 @@ export class RenoteMutingEntityService {
|
||||
@bindThis
|
||||
public packMany(
|
||||
mutings: any[],
|
||||
me: { id: User['id'] },
|
||||
me: { id: MiUser['id'] },
|
||||
) {
|
||||
return Promise.all(mutings.map(x => this.pack(x, me)));
|
||||
}
|
||||
|
@@ -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';
|
||||
|
||||
@@ -26,8 +26,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,
|
||||
) {
|
||||
const role = typeof src === 'object' ? src : await this.rolesRepository.findOneByOrFail({ id: src });
|
||||
|
||||
@@ -73,7 +73,7 @@ export class RoleEntityService {
|
||||
@bindThis
|
||||
public packMany(
|
||||
roles: any[],
|
||||
me: { id: User['id'] },
|
||||
me: { id: MiUser['id'] },
|
||||
) {
|
||||
return Promise.all(roles.map(x => this.pack(x, me)));
|
||||
}
|
||||
|
@@ -5,7 +5,7 @@
|
||||
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import type { } from '@/models/entities/Blocking.js';
|
||||
import type { Signin } from '@/models/entities/Signin.js';
|
||||
import type { MiSignin } from '@/models/entities/Signin.js';
|
||||
import { bindThis } from '@/decorators.js';
|
||||
|
||||
@Injectable()
|
||||
@@ -16,7 +16,7 @@ export class SigninEntityService {
|
||||
|
||||
@bindThis
|
||||
public async pack(
|
||||
src: Signin,
|
||||
src: MiSignin,
|
||||
) {
|
||||
return src;
|
||||
}
|
||||
|
@@ -13,9 +13,9 @@ 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, localUsernameSchema, locationSchema, nameSchema, passwordSchema } from '@/models/entities/User.js';
|
||||
import type { UsersRepository, UserSecurityKeysRepository, FollowingsRepository, FollowRequestsRepository, BlockingsRepository, MutingsRepository, DriveFilesRepository, NoteUnreadsRepository, UserNotePiningsRepository, UserProfilesRepository, AnnouncementReadsRepository, AnnouncementsRepository, UserProfile, RenoteMutingsRepository, UserMemoRepository, Announcement } from '@/models/index.js';
|
||||
import type { UsersRepository, UserSecurityKeysRepository, FollowingsRepository, FollowRequestsRepository, BlockingsRepository, MutingsRepository, DriveFilesRepository, NoteUnreadsRepository, UserNotePiningsRepository, UserProfilesRepository, AnnouncementReadsRepository, AnnouncementsRepository, MiUserProfile, RenoteMutingsRepository, UserMemoRepository } from '@/models/index.js';
|
||||
import { bindThis } from '@/decorators.js';
|
||||
import { RoleService } from '@/core/RoleService.js';
|
||||
import { ApPersonService } from '@/core/activitypub/models/ApPersonService.js';
|
||||
@@ -38,15 +38,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);
|
||||
}
|
||||
|
||||
@@ -145,7 +145,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({
|
||||
@@ -208,7 +208,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);
|
||||
|
||||
@@ -225,7 +225,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(
|
||||
@@ -239,7 +239,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,
|
||||
});
|
||||
@@ -248,7 +248,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();
|
||||
@@ -260,12 +260,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);
|
||||
}
|
||||
@@ -276,12 +276,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({
|
||||
@@ -311,7 +311,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;
|
||||
|
||||
const relation = meId && !isMe && opts.detail ? await this.getRelation(meId, user.id) : null;
|
||||
const pins = opts.detail ? await this.userNotePiningsRepository.createQueryBuilder('pin')
|
||||
@@ -491,8 +491,8 @@ export class UserEntityService implements OnModuleInit {
|
||||
}
|
||||
|
||||
public 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,
|
||||
|
@@ -8,7 +8,7 @@ import { DI } from '@/di-symbols.js';
|
||||
import type { UserListJoiningsRepository, UserListsRepository } from '@/models/index.js';
|
||||
import type { Packed } from '@/misc/json-schema.js';
|
||||
import type { } from '@/models/entities/Blocking.js';
|
||||
import type { UserList } from '@/models/entities/UserList.js';
|
||||
import type { MiUserList } from '@/models/entities/UserList.js';
|
||||
import { bindThis } from '@/decorators.js';
|
||||
|
||||
@Injectable()
|
||||
@@ -24,7 +24,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 });
|
||||
|
||||
|
Reference in New Issue
Block a user