diff --git a/packages/backend/src/core/AiService.ts b/packages/backend/src/core/AiService.ts index aee9504c8..059e335ef 100644 --- a/packages/backend/src/core/AiService.ts +++ b/packages/backend/src/core/AiService.ts @@ -6,13 +6,13 @@ import * as nsfw from 'nsfwjs'; import si from 'systeminformation'; import type { Config } from '@/config.js'; import { DI } from '@/di-symbols.js'; +import { bindThis } from '@/decorators.js'; const _filename = fileURLToPath(import.meta.url); const _dirname = dirname(_filename); const REQUIRED_CPU_FLAGS = ['avx2', 'fma']; let isSupportedCpu: undefined | boolean = undefined; -import { bindThis } from '@/decorators.js'; @Injectable() export class AiService { diff --git a/packages/backend/src/core/AppLockService.ts b/packages/backend/src/core/AppLockService.ts index 1f512b579..5f3072a41 100644 --- a/packages/backend/src/core/AppLockService.ts +++ b/packages/backend/src/core/AppLockService.ts @@ -3,12 +3,12 @@ import { Inject, Injectable } from '@nestjs/common'; import redisLock from 'redis-lock'; import Redis from 'ioredis'; import { DI } from '@/di-symbols.js'; +import { bindThis } from '@/decorators.js'; /** * Retry delay (ms) for lock acquisition */ const retryDelay = 100; -import { bindThis } from '@/decorators.js'; @Injectable() export class AppLockService { diff --git a/packages/backend/src/core/CustomEmojiService.ts b/packages/backend/src/core/CustomEmojiService.ts index 36f88fd74..ff52ad27d 100644 --- a/packages/backend/src/core/CustomEmojiService.ts +++ b/packages/backend/src/core/CustomEmojiService.ts @@ -12,6 +12,7 @@ import type { Note } from '@/models/entities/Note.js'; import type { EmojisRepository } from '@/models/index.js'; import { UtilityService } from '@/core/UtilityService.js'; import { ReactionService } from '@/core/ReactionService.js'; +import { bindThis } from '@/decorators.js'; /** * 添付用絵文字情報 @@ -20,7 +21,6 @@ type PopulatedEmoji = { name: string; url: string; }; -import { bindThis } from '@/decorators.js'; @Injectable() export class CustomEmojiService { diff --git a/packages/backend/src/core/DriveService.ts b/packages/backend/src/core/DriveService.ts index b83047dbc..895073c32 100644 --- a/packages/backend/src/core/DriveService.ts +++ b/packages/backend/src/core/DriveService.ts @@ -31,6 +31,7 @@ import { InternalStorageService } from '@/core/InternalStorageService.js'; import { DriveFileEntityService } from '@/core/entities/DriveFileEntityService.js'; import { UserEntityService } from '@/core/entities/UserEntityService.js'; import { FileInfoService } from '@/core/FileInfoService.js'; +import { bindThis } from '@/decorators.js'; import type S3 from 'aws-sdk/clients/s3.js'; type AddFileArgs = { @@ -71,7 +72,6 @@ type UploadFromUrlArgs = { requestIp?: string | null; requestHeaders?: Record | null; }; -import { bindThis } from '@/decorators.js'; @Injectable() export class DriveService { diff --git a/packages/backend/src/core/FetchInstanceMetadataService.ts b/packages/backend/src/core/FetchInstanceMetadataService.ts index 4d4945ca7..7eea45200 100644 --- a/packages/backend/src/core/FetchInstanceMetadataService.ts +++ b/packages/backend/src/core/FetchInstanceMetadataService.ts @@ -10,6 +10,7 @@ import type Logger from '@/logger.js'; import { DI } from '@/di-symbols.js'; import { LoggerService } from '@/core/LoggerService.js'; import { HttpRequestService } from '@/core/HttpRequestService.js'; +import { bindThis } from '@/decorators.js'; import type { DOMWindow } from 'jsdom'; type NodeInfo = { @@ -30,7 +31,6 @@ type NodeInfo = { themeColor?: unknown; }; }; -import { bindThis } from '@/decorators.js'; @Injectable() export class FetchInstanceMetadataService { diff --git a/packages/backend/src/core/GlobalEventService.ts b/packages/backend/src/core/GlobalEventService.ts index 90f911027..784612149 100644 --- a/packages/backend/src/core/GlobalEventService.ts +++ b/packages/backend/src/core/GlobalEventService.ts @@ -50,26 +50,32 @@ export class GlobalEventService { })); } + @bindThis public publishInternalEvent(type: K, value?: InternalStreamTypes[K]): void { this.publish('internal', type, typeof value === 'undefined' ? null : value); } + @bindThis public publishUserEvent(userId: User['id'], type: K, value?: UserStreamTypes[K]): void { this.publish(`user:${userId}`, type, typeof value === 'undefined' ? null : value); } + @bindThis public publishBroadcastStream(type: K, value?: BroadcastTypes[K]): void { this.publish('broadcast', type, typeof value === 'undefined' ? null : value); } + @bindThis public publishMainStream(userId: User['id'], type: K, value?: MainStreamTypes[K]): void { this.publish(`mainStream:${userId}`, type, typeof value === 'undefined' ? null : value); } + @bindThis public publishDriveStream(userId: User['id'], type: K, value?: DriveStreamTypes[K]): void { this.publish(`driveStream:${userId}`, type, typeof value === 'undefined' ? null : value); } + @bindThis public publishNoteStream(noteId: Note['id'], type: K, value?: NoteStreamTypes[K]): void { this.publish(`noteStream:${noteId}`, type, { id: noteId, @@ -77,26 +83,32 @@ export class GlobalEventService { }); } + @bindThis public publishChannelStream(channelId: Channel['id'], type: K, value?: ChannelStreamTypes[K]): void { this.publish(`channelStream:${channelId}`, type, typeof value === 'undefined' ? null : value); } + @bindThis public publishUserListStream(listId: UserList['id'], type: K, value?: UserListStreamTypes[K]): void { this.publish(`userListStream:${listId}`, type, typeof value === 'undefined' ? null : value); } + @bindThis public publishAntennaStream(antennaId: Antenna['id'], type: K, value?: AntennaStreamTypes[K]): void { this.publish(`antennaStream:${antennaId}`, type, typeof value === 'undefined' ? null : value); } + @bindThis public publishMessagingStream(userId: User['id'], otherpartyId: User['id'], type: K, value?: MessagingStreamTypes[K]): void { this.publish(`messagingStream:${userId}-${otherpartyId}`, type, typeof value === 'undefined' ? null : value); } + @bindThis public publishGroupMessagingStream(groupId: UserGroup['id'], type: K, value?: GroupMessagingStreamTypes[K]): void { this.publish(`messagingStream:${groupId}`, type, typeof value === 'undefined' ? null : value); } + @bindThis public publishMessagingIndexStream(userId: User['id'], type: K, value?: MessagingIndexStreamTypes[K]): void { this.publish(`messagingIndexStream:${userId}`, type, typeof value === 'undefined' ? null : value); } @@ -106,6 +118,7 @@ export class GlobalEventService { this.publish('notesStream', null, note); } + @bindThis public publishAdminStream(userId: User['id'], type: K, value?: AdminStreamTypes[K]): void { this.publish(`adminStream:${userId}`, type, typeof value === 'undefined' ? null : value); } diff --git a/packages/backend/src/core/InstanceActorService.ts b/packages/backend/src/core/InstanceActorService.ts index abd6685d6..0b4a83c63 100644 --- a/packages/backend/src/core/InstanceActorService.ts +++ b/packages/backend/src/core/InstanceActorService.ts @@ -5,9 +5,9 @@ import type { UsersRepository } from '@/models/index.js'; import { Cache } from '@/misc/cache.js'; import { DI } from '@/di-symbols.js'; import { CreateSystemUserService } from '@/core/CreateSystemUserService.js'; +import { bindThis } from '@/decorators.js'; const ACTOR_USERNAME = 'instance.actor' as const; -import { bindThis } from '@/decorators.js'; @Injectable() export class InstanceActorService { diff --git a/packages/backend/src/core/InternalStorageService.ts b/packages/backend/src/core/InternalStorageService.ts index e32cbf645..7c03af7de 100644 --- a/packages/backend/src/core/InternalStorageService.ts +++ b/packages/backend/src/core/InternalStorageService.ts @@ -5,12 +5,12 @@ import { dirname } from 'node:path'; import { Inject, Injectable } from '@nestjs/common'; import { DI } from '@/di-symbols.js'; import type { Config } from '@/config.js'; +import { bindThis } from '@/decorators.js'; const _filename = fileURLToPath(import.meta.url); const _dirname = dirname(_filename); const path = Path.resolve(_dirname, '../../../../files'); -import { bindThis } from '@/decorators.js'; @Injectable() export class InternalStorageService { diff --git a/packages/backend/src/core/MfmService.ts b/packages/backend/src/core/MfmService.ts index d53623baa..6c40ba25a 100644 --- a/packages/backend/src/core/MfmService.ts +++ b/packages/backend/src/core/MfmService.ts @@ -7,6 +7,7 @@ import type { UsersRepository } from '@/models/index.js'; import type { Config } from '@/config.js'; import { intersperse } from '@/misc/prelude/array.js'; import type { IMentionedRemoteUsers } from '@/models/entities/Note.js'; +import { bindThis } from '@/decorators.js'; import * as TreeAdapter from '../../node_modules/parse5/dist/tree-adapters/default.js'; import type * as mfm from 'mfm-js'; @@ -14,7 +15,6 @@ const treeAdapter = TreeAdapter.defaultTreeAdapter; const urlRegex = /^https?:\/\/[\w\/:%#@$&?!()\[\]~.,=+\-]+/; const urlRegexFull = /^https?:\/\/[\w\/:%#@$&?!()\[\]~.,=+\-]+$/; -import { bindThis } from '@/decorators.js'; @Injectable() export class MfmService { diff --git a/packages/backend/src/core/NoteCreateService.ts b/packages/backend/src/core/NoteCreateService.ts index a41df2805..b0a8f03af 100644 --- a/packages/backend/src/core/NoteCreateService.ts +++ b/packages/backend/src/core/NoteCreateService.ts @@ -40,6 +40,7 @@ import { ApRendererService } from '@/core/activitypub/ApRendererService.js'; import { ApDeliverManagerService } from '@/core/activitypub/ApDeliverManagerService.js'; import { NoteReadService } from '@/core/NoteReadService.js'; import { RemoteUserResolveService } from '@/core/RemoteUserResolveService.js'; +import { bindThis } from '@/decorators.js'; const mutedWordsCache = new Cache<{ userId: UserProfile['userId']; mutedWords: UserProfile['mutedWords']; }[]>(1000 * 60 * 5); @@ -132,7 +133,6 @@ type Option = { url?: string | null; app?: App | null; }; -import { bindThis } from '@/decorators.js'; @Injectable() export class NoteCreateService { diff --git a/packages/backend/src/core/PushNotificationService.ts b/packages/backend/src/core/PushNotificationService.ts index bffb24cf4..512b6025b 100644 --- a/packages/backend/src/core/PushNotificationService.ts +++ b/packages/backend/src/core/PushNotificationService.ts @@ -6,6 +6,7 @@ import type { Packed } from '@/misc/schema'; import { getNoteSummary } from '@/misc/get-note-summary.js'; import type { SwSubscriptionsRepository } from '@/models/index.js'; import { MetaService } from '@/core/MetaService.js'; +import { bindThis } from '@/decorators.js'; // Defined also packages/sw/types.ts#L14-L21 type pushNotificationsTypes = { @@ -37,7 +38,6 @@ function truncateNotification(notification: Packed<'Notification'>): any { return notification; } -import { bindThis } from '@/decorators.js'; @Injectable() export class PushNotificationService { diff --git a/packages/backend/src/core/ReactionService.ts b/packages/backend/src/core/ReactionService.ts index b02c99056..09022b57a 100644 --- a/packages/backend/src/core/ReactionService.ts +++ b/packages/backend/src/core/ReactionService.ts @@ -17,6 +17,7 @@ import { NoteEntityService } from '@/core/entities/NoteEntityService.js'; import { UserEntityService } from '@/core/entities/UserEntityService.js'; import { ApRendererService } from '@/core/activitypub/ApRendererService.js'; import { MetaService } from '@/core/MetaService.js'; +import { bindThis } from '@/decorators.js'; import { UtilityService } from './UtilityService.js'; const legacies: Record = { @@ -49,7 +50,6 @@ type DecodedReaction = { */ host?: string | null; }; -import { bindThis } from '@/decorators.js'; @Injectable() export class ReactionService { diff --git a/packages/backend/src/core/RelayService.ts b/packages/backend/src/core/RelayService.ts index 5fb853f25..a7408649b 100644 --- a/packages/backend/src/core/RelayService.ts +++ b/packages/backend/src/core/RelayService.ts @@ -10,9 +10,9 @@ import { CreateSystemUserService } from '@/core/CreateSystemUserService.js'; import { ApRendererService } from '@/core/activitypub/ApRendererService.js'; import { DI } from '@/di-symbols.js'; import { deepClone } from '@/misc/clone.js'; +import { bindThis } from '@/decorators.js'; const ACTOR_USERNAME = 'relay.actor' as const; -import { bindThis } from '@/decorators.js'; @Injectable() export class RelayService { diff --git a/packages/backend/src/core/TwoFactorAuthenticationService.ts b/packages/backend/src/core/TwoFactorAuthenticationService.ts index 150047fd2..dda78236e 100644 --- a/packages/backend/src/core/TwoFactorAuthenticationService.ts +++ b/packages/backend/src/core/TwoFactorAuthenticationService.ts @@ -4,6 +4,7 @@ import * as jsrsasign from 'jsrsasign'; import { DI } from '@/di-symbols.js'; import type { UsersRepository } from '@/models/index.js'; import type { Config } from '@/config.js'; +import { bindThis } from '@/decorators.js'; const ECC_PRELUDE = Buffer.from([0x04]); const NULL_BYTE = Buffer.from([0]); @@ -103,7 +104,6 @@ function PEMString(pemBuffer: Buffer, type = 'CERTIFICATE') { `\n-----END ${type}-----\n` ); } -import { bindThis } from '@/decorators.js'; @Injectable() export class TwoFactorAuthenticationService { diff --git a/packages/backend/src/core/UserFollowingService.ts b/packages/backend/src/core/UserFollowingService.ts index a6cb042c7..074aae86c 100644 --- a/packages/backend/src/core/UserFollowingService.ts +++ b/packages/backend/src/core/UserFollowingService.ts @@ -13,9 +13,10 @@ import { WebhookService } from '@/core/WebhookService.js'; import { CreateNotificationService } from '@/core/CreateNotificationService.js'; import { DI } from '@/di-symbols.js'; import type { BlockingsRepository, FollowingsRepository, FollowRequestsRepository, InstancesRepository, UserProfilesRepository, UsersRepository } from '@/models/index.js'; -import Logger from '../logger.js'; import { UserEntityService } from '@/core/entities/UserEntityService.js'; import { ApRendererService } from '@/core/activitypub/ApRendererService.js'; +import { bindThis } from '@/decorators.js'; +import Logger from '../logger.js'; const logger = new Logger('following/create'); @@ -31,7 +32,6 @@ type Remote = IRemoteUser | { inbox: IRemoteUser['inbox']; }; type Both = Local | Remote; -import { bindThis } from '@/decorators.js'; @Injectable() export class UserFollowingService { diff --git a/packages/backend/src/core/WebfingerService.ts b/packages/backend/src/core/WebfingerService.ts index 2d7afe5c8..4c91ab843 100644 --- a/packages/backend/src/core/WebfingerService.ts +++ b/packages/backend/src/core/WebfingerService.ts @@ -4,6 +4,7 @@ import { DI } from '@/di-symbols.js'; import type { Config } from '@/config.js'; import { query as urlQuery } from '@/misc/prelude/url.js'; import { HttpRequestService } from '@/core/HttpRequestService.js'; +import { bindThis } from '@/decorators.js'; type ILink = { href: string; @@ -14,7 +15,6 @@ type IWebFinger = { links: ILink[]; subject: string; }; -import { bindThis } from '@/decorators.js'; @Injectable() export class WebfingerService {