From 9818d1ab9edd999940c55eecd0dd3c0da7ce3f4e Mon Sep 17 00:00:00 2001 From: mattyatea Date: Sat, 14 Oct 2023 17:10:41 +0900 Subject: [PATCH] lint fix --- .../backend/src/core/UserFollowingService.ts | 9 +- .../core/entities/InstanceEntityService.ts | 11 +- packages/backend/src/misc/fetch-meta.ts | 10 +- .../backend/src/misc/should-block-instance.ts | 12 +- .../server/api/endpoints/admin/update-meta.ts | 190 +++++++++--------- .../frontend/src/pages/about.federation.vue | 4 +- .../src/pages/admin/instance-block.vue | 25 +-- 7 files changed, 130 insertions(+), 131 deletions(-) diff --git a/packages/backend/src/core/UserFollowingService.ts b/packages/backend/src/core/UserFollowingService.ts index 0a314c1193..0180a23b81 100644 --- a/packages/backend/src/core/UserFollowingService.ts +++ b/packages/backend/src/core/UserFollowingService.ts @@ -3,9 +3,9 @@ * SPDX-License-Identifier: AGPL-3.0-only */ -import { Inject, Injectable, OnModuleInit, forwardRef } from '@nestjs/common'; +import { Inject, Injectable, OnModuleInit } from '@nestjs/common'; import { ModuleRef } from '@nestjs/core'; -import {DataSource, IsNull } from 'typeorm'; +import { DataSource, IsNull } from 'typeorm'; import type { MiLocalUser, MiPartialLocalUser, MiPartialRemoteUser, MiRemoteUser, MiUser } from '@/models/User.js'; import { IdentifiableError } from '@/misc/identifiable-error.js'; import { QueueService } from '@/core/QueueService.js'; @@ -28,9 +28,8 @@ import { MetaService } from '@/core/MetaService.js'; import { CacheService } from '@/core/CacheService.js'; import type { Config } from '@/config.js'; import { AccountMoveService } from '@/core/AccountMoveService.js'; +import { shouldSilenceInstance } from '@/misc/should-block-instance.js'; import Logger from '../logger.js'; -import { shouldSilenceInstance } from "@/misc/should-block-instance.js"; - const logger = new Logger('following/create'); @@ -133,7 +132,7 @@ export class UserFollowingService implements OnModuleInit { followee.isLocked || (followeeProfile.carefulBot && follower.isBot) || (this.userEntityService.isLocalUser(follower) && this.userEntityService.isRemoteUser(followee) && process.env.FORCE_FOLLOW_REMOTE_USER_FOR_TESTING !== 'true') || - ( this.userEntityService.isLocalUser(followee) && this.userEntityService.isRemoteUser(follower) && await shouldSilenceInstance(follower.host,this.db)) + ( this.userEntityService.isLocalUser(followee) && this.userEntityService.isRemoteUser(follower) && await shouldSilenceInstance(follower.host, this.db)) ) { let autoAccept = false; diff --git a/packages/backend/src/core/entities/InstanceEntityService.ts b/packages/backend/src/core/entities/InstanceEntityService.ts index 15c1d07c1b..a09a4d69ca 100644 --- a/packages/backend/src/core/entities/InstanceEntityService.ts +++ b/packages/backend/src/core/entities/InstanceEntityService.ts @@ -3,16 +3,15 @@ * SPDX-License-Identifier: AGPL-3.0-only */ -import {Inject, Injectable} from '@nestjs/common'; +import { Inject, Injectable } from '@nestjs/common'; +import { DataSource } from 'typeorm'; import type { Packed } from '@/misc/json-schema.js'; -import type { } from '@/models/Blocking.js'; import type { MiInstance } from '@/models/Instance.js'; import { MetaService } from '@/core/MetaService.js'; import { bindThis } from '@/decorators.js'; +import { shouldSilenceInstance } from '@/misc/should-block-instance.js'; +import { DI } from '@/di-symbols.js'; import { UtilityService } from '../UtilityService.js'; -import {shouldSilenceInstance} from "@/misc/should-block-instance.js"; -import { DataSource } from 'typeorm'; -import {DI} from "@/di-symbols.js"; @Injectable() export class InstanceEntityService { @@ -49,7 +48,7 @@ export class InstanceEntityService { description: instance.description, maintainerName: instance.maintainerName, maintainerEmail: instance.maintainerEmail, - isSilenced: await shouldSilenceInstance(instance.host,this.db), + isSilenced: await shouldSilenceInstance(instance.host, this.db), iconUrl: instance.iconUrl, faviconUrl: instance.faviconUrl, themeColor: instance.themeColor, diff --git a/packages/backend/src/misc/fetch-meta.ts b/packages/backend/src/misc/fetch-meta.ts index 99964a300a..cd86477f9b 100644 --- a/packages/backend/src/misc/fetch-meta.ts +++ b/packages/backend/src/misc/fetch-meta.ts @@ -1,16 +1,16 @@ import { DataSource } from 'typeorm'; -import { MiMeta } from "@/models/Meta.js"; +import { MiMeta } from '@/models/Meta.js'; let cache: MiMeta; -export async function fetchMeta(noCache = false , db: DataSource): Promise { +export async function fetchMeta(noCache = false, db: DataSource): Promise { if (!noCache && cache) return cache; return await db.transaction(async (transactionalEntityManager) => { // New IDs are prioritized because multiple records may have been created due to past bugs. const metas = await transactionalEntityManager.find(MiMeta, { order: { - id: "DESC", + id: 'DESC', }, }); @@ -25,9 +25,9 @@ export async function fetchMeta(noCache = false , db: DataSource): Promise transactionalEntityManager.findOneByOrFail(MiMeta, x.identifiers[0]), diff --git a/packages/backend/src/misc/should-block-instance.ts b/packages/backend/src/misc/should-block-instance.ts index 0c38d3867e..666ff2815e 100644 --- a/packages/backend/src/misc/should-block-instance.ts +++ b/packages/backend/src/misc/should-block-instance.ts @@ -1,14 +1,14 @@ -import { fetchMeta } from "@/misc/fetch-meta.js"; -import type { MiInstance } from "@/models/Instance.js"; -import type { MiMeta } from "@/models/Meta.js"; -import { DataSource } from "typeorm"; +import { DataSource } from 'typeorm'; +import { fetchMeta } from '@/misc/fetch-meta.js'; +import type { MiInstance } from '@/models/Instance.js'; +import type { MiMeta } from '@/models/Meta.js'; export async function shouldSilenceInstance( - host: MiInstance["host"], + host: MiInstance['host'], db : DataSource, meta?: MiMeta, ): Promise { - const { silencedHosts } = meta ?? (await fetchMeta(true,db)); + const { silencedHosts } = meta ?? (await fetchMeta(true, db)); return silencedHosts.some( (limitedHost: string) => host === limitedHost || host.endsWith(`.${limitedHost}`), ); diff --git a/packages/backend/src/server/api/endpoints/admin/update-meta.ts b/packages/backend/src/server/api/endpoints/admin/update-meta.ts index c2d1f19b89..72c4936c13 100644 --- a/packages/backend/src/server/api/endpoints/admin/update-meta.ts +++ b/packages/backend/src/server/api/endpoints/admin/update-meta.ts @@ -3,11 +3,11 @@ * SPDX-License-Identifier: AGPL-3.0-only */ -import {Injectable} from '@nestjs/common'; -import type {MiMeta} from '@/models/Meta.js'; -import {ModerationLogService} from '@/core/ModerationLogService.js'; -import {Endpoint} from '@/server/api/endpoint-base.js'; -import {MetaService} from '@/core/MetaService.js'; +import { Injectable } from '@nestjs/common'; +import type { MiMeta } from '@/models/Meta.js'; +import { ModerationLogService } from '@/core/ModerationLogService.js'; +import { Endpoint } from '@/server/api/endpoint-base.js'; +import { MetaService } from '@/core/MetaService.js'; export const meta = { tags: ['admin'], @@ -19,117 +19,117 @@ export const meta = { export const paramDef = { type: 'object', properties: { - disableRegistration: {type: 'boolean', nullable: true}, + disableRegistration: { type: 'boolean', nullable: true }, pinnedUsers: { type: 'array', nullable: true, items: { type: 'string', - } + }, }, hiddenTags: { type: 'array', nullable: true, items: { type: 'string', - } + }, }, blockedHosts: { type: 'array', nullable: true, items: { type: 'string', - } + }, }, sensitiveWords: { type: 'array', nullable: true, items: { type: 'string', - } + }, }, - themeColor: {type: 'string', nullable: true, pattern: '^#[0-9a-fA-F]{6}$'}, - mascotImageUrl: {type: 'string', nullable: true}, - bannerUrl: {type: 'string', nullable: true}, - serverErrorImageUrl: {type: 'string', nullable: true}, - infoImageUrl: {type: 'string', nullable: true}, - notFoundImageUrl: {type: 'string', nullable: true}, - iconUrl: {type: 'string', nullable: true}, - app192IconUrl: {type: 'string', nullable: true}, - app512IconUrl: {type: 'string', nullable: true}, - backgroundImageUrl: {type: 'string', nullable: true}, - logoImageUrl: {type: 'string', nullable: true}, - name: {type: 'string', nullable: true}, - shortName: {type: 'string', nullable: true}, - description: {type: 'string', nullable: true}, - defaultLightTheme: {type: 'string', nullable: true}, - defaultDarkTheme: {type: 'string', nullable: true}, - cacheRemoteFiles: {type: 'boolean'}, - cacheRemoteSensitiveFiles: {type: 'boolean'}, - emailRequiredForSignup: {type: 'boolean'}, - enableHcaptcha: {type: 'boolean'}, - hcaptchaSiteKey: {type: 'string', nullable: true}, - hcaptchaSecretKey: {type: 'string', nullable: true}, - enableRecaptcha: {type: 'boolean'}, - recaptchaSiteKey: {type: 'string', nullable: true}, - recaptchaSecretKey: {type: 'string', nullable: true}, - enableTurnstile: {type: 'boolean'}, - turnstileSiteKey: {type: 'string', nullable: true}, - turnstileSecretKey: {type: 'string', nullable: true}, - sensitiveMediaDetection: {type: 'string', enum: ['none', 'all', 'local', 'remote']}, - sensitiveMediaDetectionSensitivity: {type: 'string', enum: ['medium', 'low', 'high', 'veryLow', 'veryHigh']}, - setSensitiveFlagAutomatically: {type: 'boolean'}, - enableSensitiveMediaDetectionForVideos: {type: 'boolean'}, - proxyAccountId: {type: 'string', format: 'misskey:id', nullable: true}, - maintainerName: {type: 'string', nullable: true}, - maintainerEmail: {type: 'string', nullable: true}, + themeColor: { type: 'string', nullable: true, pattern: '^#[0-9a-fA-F]{6}$' }, + mascotImageUrl: { type: 'string', nullable: true }, + bannerUrl: { type: 'string', nullable: true }, + serverErrorImageUrl: { type: 'string', nullable: true }, + infoImageUrl: { type: 'string', nullable: true }, + notFoundImageUrl: { type: 'string', nullable: true }, + iconUrl: { type: 'string', nullable: true }, + app192IconUrl: { type: 'string', nullable: true }, + app512IconUrl: { type: 'string', nullable: true }, + backgroundImageUrl: { type: 'string', nullable: true }, + logoImageUrl: { type: 'string', nullable: true }, + name: { type: 'string', nullable: true }, + shortName: { type: 'string', nullable: true }, + description: { type: 'string', nullable: true }, + defaultLightTheme: { type: 'string', nullable: true }, + defaultDarkTheme: { type: 'string', nullable: true }, + cacheRemoteFiles: { type: 'boolean' }, + cacheRemoteSensitiveFiles: { type: 'boolean' }, + emailRequiredForSignup: { type: 'boolean' }, + enableHcaptcha: { type: 'boolean' }, + hcaptchaSiteKey: { type: 'string', nullable: true }, + hcaptchaSecretKey: { type: 'string', nullable: true }, + enableRecaptcha: { type: 'boolean' }, + recaptchaSiteKey: { type: 'string', nullable: true }, + recaptchaSecretKey: { type: 'string', nullable: true }, + enableTurnstile: { type: 'boolean' }, + turnstileSiteKey: { type: 'string', nullable: true }, + turnstileSecretKey: { type: 'string', nullable: true }, + sensitiveMediaDetection: { type: 'string', enum: ['none', 'all', 'local', 'remote'] }, + sensitiveMediaDetectionSensitivity: { type: 'string', enum: ['medium', 'low', 'high', 'veryLow', 'veryHigh'] }, + setSensitiveFlagAutomatically: { type: 'boolean' }, + enableSensitiveMediaDetectionForVideos: { type: 'boolean' }, + proxyAccountId: { type: 'string', format: 'misskey:id', nullable: true }, + maintainerName: { type: 'string', nullable: true }, + maintainerEmail: { type: 'string', nullable: true }, langs: { type: 'array', items: { type: 'string', - } + }, }, - summalyProxy: {type: 'string', nullable: true}, - deeplAuthKey: {type: 'string', nullable: true}, - deeplIsPro: {type: 'boolean'}, - enableEmail: {type: 'boolean'}, - email: {type: 'string', nullable: true}, - smtpSecure: {type: 'boolean'}, - smtpHost: {type: 'string', nullable: true}, - smtpPort: {type: 'integer', nullable: true}, - smtpUser: {type: 'string', nullable: true}, - smtpPass: {type: 'string', nullable: true}, - enableServiceWorker: {type: 'boolean'}, - swPublicKey: {type: 'string', nullable: true}, - swPrivateKey: {type: 'string', nullable: true}, - tosUrl: {type: 'string', nullable: true}, - repositoryUrl: {type: 'string'}, - feedbackUrl: {type: 'string'}, - impressumUrl: {type: 'string'}, - privacyPolicyUrl: {type: 'string'}, - useObjectStorage: {type: 'boolean'}, - objectStorageBaseUrl: {type: 'string', nullable: true}, - objectStorageBucket: {type: 'string', nullable: true}, - objectStoragePrefix: {type: 'string', nullable: true}, - objectStorageEndpoint: {type: 'string', nullable: true}, - objectStorageRegion: {type: 'string', nullable: true}, - objectStoragePort: {type: 'integer', nullable: true}, - objectStorageAccessKey: {type: 'string', nullable: true}, - objectStorageSecretKey: {type: 'string', nullable: true}, - objectStorageUseSSL: {type: 'boolean'}, - objectStorageUseProxy: {type: 'boolean'}, - objectStorageSetPublicRead: {type: 'boolean'}, - objectStorageS3ForcePathStyle: {type: 'boolean'}, - enableIpLogging: {type: 'boolean'}, - enableActiveEmailValidation: {type: 'boolean'}, - enableChartsForRemoteUser: {type: 'boolean'}, - enableChartsForFederatedInstances: {type: 'boolean'}, - enableServerMachineStats: {type: 'boolean'}, - enableIdenticonGeneration: {type: 'boolean'}, - serverRules: {type: 'array', items: {type: 'string'}}, - preservedUsernames: {type: 'array', items: {type: 'string'}}, - manifestJsonOverride: {type: 'string'}, - perLocalUserUserTimelineCacheMax: {type: 'integer'}, - perRemoteUserUserTimelineCacheMax: {type: 'integer'}, - perUserHomeTimelineCacheMax: {type: 'integer'}, - perUserListTimelineCacheMax: {type: 'integer'}, - notesPerOneAd: {type: 'integer'}, + summalyProxy: { type: 'string', nullable: true }, + deeplAuthKey: { type: 'string', nullable: true }, + deeplIsPro: { type: 'boolean' }, + enableEmail: { type: 'boolean' }, + email: { type: 'string', nullable: true }, + smtpSecure: { type: 'boolean' }, + smtpHost: { type: 'string', nullable: true }, + smtpPort: { type: 'integer', nullable: true }, + smtpUser: { type: 'string', nullable: true }, + smtpPass: { type: 'string', nullable: true }, + enableServiceWorker: { type: 'boolean' }, + swPublicKey: { type: 'string', nullable: true }, + swPrivateKey: { type: 'string', nullable: true }, + tosUrl: { type: 'string', nullable: true }, + repositoryUrl: { type: 'string' }, + feedbackUrl: { type: 'string' }, + impressumUrl: { type: 'string' }, + privacyPolicyUrl: { type: 'string' }, + useObjectStorage: { type: 'boolean' }, + objectStorageBaseUrl: { type: 'string', nullable: true }, + objectStorageBucket: { type: 'string', nullable: true }, + objectStoragePrefix: { type: 'string', nullable: true }, + objectStorageEndpoint: { type: 'string', nullable: true }, + objectStorageRegion: { type: 'string', nullable: true }, + objectStoragePort: { type: 'integer', nullable: true }, + objectStorageAccessKey: { type: 'string', nullable: true }, + objectStorageSecretKey: { type: 'string', nullable: true }, + objectStorageUseSSL: { type: 'boolean' }, + objectStorageUseProxy: { type: 'boolean' }, + objectStorageSetPublicRead: { type: 'boolean' }, + objectStorageS3ForcePathStyle: { type: 'boolean' }, + enableIpLogging: { type: 'boolean' }, + enableActiveEmailValidation: { type: 'boolean' }, + enableChartsForRemoteUser: { type: 'boolean' }, + enableChartsForFederatedInstances: { type: 'boolean' }, + enableServerMachineStats: { type: 'boolean' }, + enableIdenticonGeneration: { type: 'boolean' }, + serverRules: { type: 'array', items: { type: 'string' } }, + preservedUsernames: { type: 'array', items: { type: 'string' } }, + manifestJsonOverride: { type: 'string' }, + perLocalUserUserTimelineCacheMax: { type: 'integer' }, + perRemoteUserUserTimelineCacheMax: { type: 'integer' }, + perUserHomeTimelineCacheMax: { type: 'integer' }, + perUserListTimelineCacheMax: { type: 'integer' }, + notesPerOneAd: { type: 'integer' }, silencedHosts: { - type: "array", + type: 'array', nullable: true, items: { - type: "string", + type: 'string', }, }, }, @@ -165,11 +165,11 @@ export default class extends Endpoint { // eslint- set.sensitiveWords = ps.sensitiveWords.filter(Boolean); } if (Array.isArray(ps.silencedHosts)) { - let lastValue = ""; + let lastValue = ''; set.silencedHosts = ps.silencedHosts.sort().filter((h) => { const lv = lastValue; lastValue = h; - return h !== "" && h !== lv && !set.blockedHosts?.includes(h); + return h !== '' && h !== lv && !set.blockedHosts?.includes(h); }); } if (ps.themeColor !== undefined) { diff --git a/packages/frontend/src/pages/about.federation.vue b/packages/frontend/src/pages/about.federation.vue index 4798160f15..333af93ef8 100644 --- a/packages/frontend/src/pages/about.federation.vue +++ b/packages/frontend/src/pages/about.federation.vue @@ -76,7 +76,7 @@ const pagination = { state === 'publishing' ? { publishing: true } : state === 'suspended' ? { suspended: true } : state === 'blocked' ? { blocked: true } : - state === 'silenced' ? {silenced: true} : + state === 'silenced' ? { silenced: true } : state === 'notResponding' ? { notResponding: true } : {}), })), @@ -85,7 +85,7 @@ const pagination = { function getStatus(instance) { if (instance.isSuspended) return 'Suspended'; if (instance.isBlocked) return 'Blocked'; - if (instance.isSilenced) return 'Silenced' + if (instance.isSilenced) return 'Silenced'; if (instance.isNotResponding) return 'Error'; return 'Alive'; } diff --git a/packages/frontend/src/pages/admin/instance-block.vue b/packages/frontend/src/pages/admin/instance-block.vue index 35ee8a9379..01689b9658 100644 --- a/packages/frontend/src/pages/admin/instance-block.vue +++ b/packages/frontend/src/pages/admin/instance-block.vue @@ -5,8 +5,8 @@ SPDX-License-Identifier: AGPL-3.0-only