diff --git a/packages/backend/src/core/DriveService.ts b/packages/backend/src/core/DriveService.ts index 643c51c37d..e0bdd29c0f 100644 --- a/packages/backend/src/core/DriveService.ts +++ b/packages/backend/src/core/DriveService.ts @@ -61,7 +61,7 @@ type AddFileArgs = { type UploadFromUrlArgs = { url: string; - user: { id: User['id']; host: User['host'] } | null; + user: { id: User['id']; host: User['host']; driveCapacityOverrideMb: User['driveCapacityOverrideMb'] } | null; folderId?: DriveFolder['id'] | null; uri?: string | null; sensitive?: boolean; diff --git a/packages/backend/src/core/FetchInstanceMetadataService.ts b/packages/backend/src/core/FetchInstanceMetadataService.ts index 9a51ed0c0a..184404123c 100644 --- a/packages/backend/src/core/FetchInstanceMetadataService.ts +++ b/packages/backend/src/core/FetchInstanceMetadataService.ts @@ -13,20 +13,21 @@ import { HttpRequestService } from './HttpRequestService.js'; import type { DOMWindow } from 'jsdom'; type NodeInfo = { - openRegistrations?: any; + openRegistrations?: unknown; software?: { - name?: any; - version?: any; + name?: unknown; + version?: unknown; }; metadata?: { - name?: any; - nodeName?: any; - nodeDescription?: any; - description?: any; + name?: unknown; + nodeName?: unknown; + nodeDescription?: unknown; + description?: unknown; maintainer?: { - name?: any; - email?: any; + name?: unknown; + email?: unknown; }; + themeColor?: unknown; }; }; @@ -81,7 +82,7 @@ export class FetchInstanceMetadataService { } as Record; if (info) { - updates.softwareName = info.software?.name.toLowerCase(); + updates.softwareName = typeof info.software?.name === 'string' ? info.software.name.toLowerCase() : '?'; updates.softwareVersion = info.software?.version; updates.openRegistrations = info.openRegistrations; updates.maintainerName = info.metadata ? info.metadata.maintainer ? (info.metadata.maintainer.name ?? null) : null : null; @@ -238,8 +239,10 @@ export class FetchInstanceMetadataService { private async getSiteName(info: NodeInfo | null, doc: DOMWindow['document'] | null, manifest: Record | null): Promise { if (info && info.metadata) { - if (info.metadata.nodeName || info.metadata.name) { - return info.metadata.nodeName ?? info.metadata.name; + if (typeof info.metadata.nodeName === 'string') { + return info.metadata.nodeName; + } else if (typeof info.metadata.name === 'string') { + return info.metadata.name; } } @@ -260,8 +263,10 @@ export class FetchInstanceMetadataService { private async getDescription(info: NodeInfo | null, doc: DOMWindow['document'] | null, manifest: Record | null): Promise { if (info && info.metadata) { - if (info.metadata.nodeDescription || info.metadata.description) { - return info.metadata.nodeDescription ?? info.metadata.description; + if (typeof info.metadata.nodeDescription === 'string') { + return info.metadata.nodeDescription; + } else if (typeof info.metadata.description === 'string') { + return info.metadata.description; } } diff --git a/packages/backend/src/core/MetaService.ts b/packages/backend/src/core/MetaService.ts index 1744f64217..c3d41bfccb 100644 --- a/packages/backend/src/core/MetaService.ts +++ b/packages/backend/src/core/MetaService.ts @@ -34,7 +34,7 @@ export class MetaService implements OnApplicationShutdown { this.redisSubscriber.on('message', this.onMessage); } - private async onMessage(_, data): Promise { + private async onMessage(_: string, data: string): Promise { const obj = JSON.parse(data); if (obj.channel === 'internal') { diff --git a/packages/backend/src/core/NoteCreateService.ts b/packages/backend/src/core/NoteCreateService.ts index 6e5cce8f62..a23e105674 100644 --- a/packages/backend/src/core/NoteCreateService.ts +++ b/packages/backend/src/core/NoteCreateService.ts @@ -534,7 +534,6 @@ export class NoteCreateService { }); const nm = new NotificationManager(this.mutingsRepository, this.createNotificationService, user, note); - const nmRelatedPromises = []; await this.createMentionedEvents(mentionedUsers, note, nm); @@ -583,9 +582,7 @@ export class NoteCreateService { } } - Promise.all(nmRelatedPromises).then(() => { - nm.deliver(); - }); + nm.deliver(); //#region AP deliver if (this.userEntityService.isLocalUser(user)) { diff --git a/packages/backend/src/core/SignupService.ts b/packages/backend/src/core/SignupService.ts index 8b72d73af6..2239d5fd83 100644 --- a/packages/backend/src/core/SignupService.ts +++ b/packages/backend/src/core/SignupService.ts @@ -3,7 +3,7 @@ import { Inject, Injectable } from '@nestjs/common'; import bcrypt from 'bcryptjs'; import { DataSource, IsNull } from 'typeorm'; import { DI } from '@/di-symbols.js'; -import type { UsedUsernamesRepository } from '@/models/index.js'; +import type { UsedUsernamesRepository, UsersRepository } from '@/models/index.js'; import type { Config } from '@/config.js'; import { User } from '@/models/entities/User.js'; import { UserProfile } from '@/models/entities/UserProfile.js'; diff --git a/packages/backend/src/core/TwoFactorAuthenticationService.ts b/packages/backend/src/core/TwoFactorAuthenticationService.ts index 0962f88a7c..54e87ec36f 100644 --- a/packages/backend/src/core/TwoFactorAuthenticationService.ts +++ b/packages/backend/src/core/TwoFactorAuthenticationService.ts @@ -67,6 +67,8 @@ function verifyCertificateChain(certificates: string[]) { const CACert = i + 1 >= certificates.length ? Cert : certificates[i + 1]; const certStruct = jsrsasign.ASN1HEX.getTLVbyList(certificate.hex!, 0, [0]); + if (certStruct == null) throw new Error('certStruct is null'); + const algorithm = certificate.getSignatureAlgorithmField(); const signatureHex = certificate.getSignatureValueHex(); diff --git a/packages/backend/src/core/UserBlockingService.ts b/packages/backend/src/core/UserBlockingService.ts index 5ff76b48a9..b7a434684e 100644 --- a/packages/backend/src/core/UserBlockingService.ts +++ b/packages/backend/src/core/UserBlockingService.ts @@ -9,12 +9,16 @@ import PerUserFollowingChart from '@/core/chart/charts/per-user-following.js'; import { DI } from '@/di-symbols.js'; import logger from '@/logger.js'; import type { UsersRepository, FollowingsRepository, FollowRequestsRepository, BlockingsRepository, UserListsRepository, UserListJoiningsRepository } from '@/models/index.js'; +import Logger from '@/logger.js'; import { UserEntityService } from './entities/UserEntityService.js'; import { WebhookService } from './WebhookService.js'; import { ApRendererService } from './remote/activitypub/ApRendererService.js'; +import { LoggerService } from './LoggerService.js'; @Injectable() export class UserBlockingService { + private logger: Logger; + constructor( @Inject(DI.usersRepository) private usersRepository: UsersRepository, @@ -41,7 +45,9 @@ export class UserBlockingService { private webhookService: WebhookService, private apRendererService: ApRendererService, private perUserFollowingChart: PerUserFollowingChart, + private loggerService: LoggerService, ) { + this.logger = this.loggerService.getLogger('user-block'); } public async block(blocker: User, blockee: User) { @@ -181,7 +187,7 @@ export class UserBlockingService { }); if (blocking == null) { - logger.warn('ブロック解除がリクエストされましたがブロックしていませんでした'); + this.logger.warn('ブロック解除がリクエストされましたがブロックしていませんでした'); return; } diff --git a/packages/backend/src/core/UserCacheService.ts b/packages/backend/src/core/UserCacheService.ts index 666bef3f49..b7166010ee 100644 --- a/packages/backend/src/core/UserCacheService.ts +++ b/packages/backend/src/core/UserCacheService.ts @@ -33,7 +33,7 @@ export class UserCacheService implements OnApplicationShutdown { this.redisSubscriber.on('message', this.onMessage); } - private async onMessage(_, data) { + private async onMessage(_: string, data: string): Promise { const obj = JSON.parse(data); if (obj.channel === 'internal') { diff --git a/packages/backend/src/core/WebhookService.ts b/packages/backend/src/core/WebhookService.ts index 347b2b16c4..1a690314f8 100644 --- a/packages/backend/src/core/WebhookService.ts +++ b/packages/backend/src/core/WebhookService.ts @@ -32,7 +32,7 @@ export class WebhookService implements OnApplicationShutdown { return this.webhooks; } - private async onMessage(_, data) { + private async onMessage(_: string, data: string): Promise { const obj = JSON.parse(data); if (obj.channel === 'internal') { diff --git a/packages/backend/src/server/api/endpoints/i/authorized-apps.ts b/packages/backend/src/server/api/endpoints/i/authorized-apps.ts index d0bdb5695b..f5a946eb91 100644 --- a/packages/backend/src/server/api/endpoints/i/authorized-apps.ts +++ b/packages/backend/src/server/api/endpoints/i/authorized-apps.ts @@ -1,4 +1,5 @@ import { Inject, Injectable } from '@nestjs/common'; +import { IsNull, Not } from 'typeorm'; import { Endpoint } from '@/server/api/endpoint-base.js'; import type { AccessTokensRepository } from '@/models/index.js'; import { AppEntityService } from '@/core/entities/AppEntityService.js'; @@ -34,6 +35,7 @@ export default class extends Endpoint { const tokens = await this.accessTokensRepository.find({ where: { userId: me.id, + appId: Not(IsNull()), }, take: ps.limit, skip: ps.offset, @@ -42,7 +44,7 @@ export default class extends Endpoint { }, }); - return await Promise.all(tokens.map(token => this.appEntityService.pack(token.appId, me, { + return await Promise.all(tokens.map(token => this.appEntityService.pack(token.appId!, me, { detail: true, }))); });