diff --git a/packages/backend/src/core/AiService.ts b/packages/backend/src/core/AiService.ts index aee9504c858e4b0a33b8afc741cceb03fb6f7d95..059e335effa720dc9f9e1df916f888e50d2c015e 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 1f512b5790b5e6e36a80ef77c212b7df82bd98ef..5f3072a4156fe383b1eb0329e9319f05f5282ce0 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 36f88fd7435604fa0c0428ad4404a5befb079189..ff52ad27d64baa170a7dfa20ae62e91a3758cda6 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 b83047dbc21824cab98987c9d6a0c33fc90c2354..895073c32c9cca379d972cd48e34bab152e73523 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<string, string> | 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 4d4945ca7fe4a8be184f12f34d3127db457f4f60..7eea45200ebef6726b8a4b13147d13db078b90d5 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 90f911027ee214c4dc885f14f39dd2f7fa90a7c5..784612149d7772a7b831555a9d5b2b2a389a6033 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<K extends keyof InternalStreamTypes>(type: K, value?: InternalStreamTypes[K]): void { this.publish('internal', type, typeof value === 'undefined' ? null : value); } + @bindThis public publishUserEvent<K extends keyof UserStreamTypes>(userId: User['id'], type: K, value?: UserStreamTypes[K]): void { this.publish(`user:${userId}`, type, typeof value === 'undefined' ? null : value); } + @bindThis public publishBroadcastStream<K extends keyof BroadcastTypes>(type: K, value?: BroadcastTypes[K]): void { this.publish('broadcast', type, typeof value === 'undefined' ? null : value); } + @bindThis public publishMainStream<K extends keyof MainStreamTypes>(userId: User['id'], type: K, value?: MainStreamTypes[K]): void { this.publish(`mainStream:${userId}`, type, typeof value === 'undefined' ? null : value); } + @bindThis public publishDriveStream<K extends keyof DriveStreamTypes>(userId: User['id'], type: K, value?: DriveStreamTypes[K]): void { this.publish(`driveStream:${userId}`, type, typeof value === 'undefined' ? null : value); } + @bindThis public publishNoteStream<K extends keyof NoteStreamTypes>(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<K extends keyof ChannelStreamTypes>(channelId: Channel['id'], type: K, value?: ChannelStreamTypes[K]): void { this.publish(`channelStream:${channelId}`, type, typeof value === 'undefined' ? null : value); } + @bindThis public publishUserListStream<K extends keyof UserListStreamTypes>(listId: UserList['id'], type: K, value?: UserListStreamTypes[K]): void { this.publish(`userListStream:${listId}`, type, typeof value === 'undefined' ? null : value); } + @bindThis public publishAntennaStream<K extends keyof AntennaStreamTypes>(antennaId: Antenna['id'], type: K, value?: AntennaStreamTypes[K]): void { this.publish(`antennaStream:${antennaId}`, type, typeof value === 'undefined' ? null : value); } + @bindThis public publishMessagingStream<K extends keyof MessagingStreamTypes>(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<K extends keyof GroupMessagingStreamTypes>(groupId: UserGroup['id'], type: K, value?: GroupMessagingStreamTypes[K]): void { this.publish(`messagingStream:${groupId}`, type, typeof value === 'undefined' ? null : value); } + @bindThis public publishMessagingIndexStream<K extends keyof MessagingIndexStreamTypes>(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<K extends keyof AdminStreamTypes>(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 abd6685d61a8d18c352c9c5afe8dfbd0e728006f..0b4a83c634c855354cc6aa42a923e18135043747 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 e32cbf645c1694fd2299ec4cdd462777c43316b1..7c03af7de7bea51c72fda9e6e9125e4b199841af 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 d53623baaa6188668e69806e79b49ce2e7f13bd3..6c40ba25a1faaac97f97f276ea13efd52bb6928f 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 a41df280500d13061e49f36eab44e35821942167..b0a8f03af1ee24aaf343538c217fcfd584e58a51 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 bffb24cf4cb5a71faf69739236e13a215b047c03..512b6025b3af9b11d086eae9ba109002b0e32f26 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 b02c9905669fcba85c1505c44c936590ddce12d6..09022b57abad37ba7b2b1d5b1f48df779490c953 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<string, string> = { @@ -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 5fb853f25a14c3087afd2abc74b6a8f23fd03d2a..a7408649b88360f592bd068aae7093d8e0db1e29 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 150047fd226cfaf61c527cd9dfd69c7b8d8451b5..dda78236e9099b45c91c292bbbf36c1ceb26a9a2 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 a6cb042c7d237cebacc5699e2ce2b8e5b6f33924..074aae86c81ba5a7b8569138175d329b4c9be802 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 2d7afe5c88c4e16d3f86be8970342e2cf572b823..4c91ab8438c4888531908a32eda338f49437ff4b 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 {