From 57331536f2c2c17d00dc69986c04ef3db29d96ad Mon Sep 17 00:00:00 2001 From: mattyatea Date: Sat, 14 Oct 2023 17:00:14 +0900 Subject: [PATCH] lint fix --- .../backend/src/core/CustomEmojiService.ts | 12 +-- .../backend/src/core/UserFollowingService.ts | 73 ++++++++++----- .../api/endpoints/admin/emoji/add-draft.ts | 4 +- .../server/api/endpoints/admin/emoji/add.ts | 22 +++-- .../api/endpoints/admin/emoji/update.ts | 4 +- .../src/components/MkEmojiEditDialog.vue | 93 +++++++++---------- .../src/components/global/MkCustomEmoji.vue | 2 +- packages/frontend/src/custom-emojis.ts | 2 +- packages/frontend/src/navbar.ts | 1 - packages/frontend/src/pages/about.emojis.vue | 46 ++++++--- .../frontend/src/pages/about.federation.vue | 5 +- .../src/pages/admin/instance-block.vue | 6 +- 12 files changed, 157 insertions(+), 113 deletions(-) diff --git a/packages/backend/src/core/CustomEmojiService.ts b/packages/backend/src/core/CustomEmojiService.ts index 332a909b8c..99dbc9d54d 100644 --- a/packages/backend/src/core/CustomEmojiService.ts +++ b/packages/backend/src/core/CustomEmojiService.ts @@ -16,10 +16,8 @@ import type { EmojisRepository, MiRole, MiUser } from '@/models/_.js'; import { bindThis } from '@/decorators.js'; import { MemoryKVCache, RedisSingleCache } from '@/misc/cache.js'; import { UtilityService } from '@/core/UtilityService.js'; -import { query } from '@/misc/prelude/url.js'; import type { Serialized } from '@/types.js'; import { ModerationLogService } from '@/core/ModerationLogService.js'; - const parseEmojiStrRegexp = /^(\w+)(?:@([\w.-]+))?$/; @Injectable() @@ -31,12 +29,6 @@ export class CustomEmojiService implements OnApplicationShutdown { @Inject(DI.redis) private redisClient: Redis.Redis, - @Inject(DI.config) - private config: Config, - - @Inject(DI.db) - private db: DataSource, - @Inject(DI.emojisRepository) private emojisRepository: EmojisRepository, @@ -119,7 +111,7 @@ export class CustomEmojiService implements OnApplicationShutdown { license?: string | null; isSensitive?: boolean; localOnly?: boolean; - draft: boolean; + draft: boolean; roleIdsThatCanBeUsedThisEmojiAsReaction?: MiRole['id'][]; }, moderator?: MiUser): Promise { const emoji = await this.emojisRepository.findOneByOrFail({ id: id }); @@ -134,7 +126,7 @@ export class CustomEmojiService implements OnApplicationShutdown { license: data.license, isSensitive: data.isSensitive, localOnly: data.localOnly, - draft: data.draft, + draft: data.draft, roleIdsThatCanBeUsedThisEmojiAsReaction: data.roleIdsThatCanBeUsedThisEmojiAsReaction ?? undefined, }); diff --git a/packages/backend/src/core/UserFollowingService.ts b/packages/backend/src/core/UserFollowingService.ts index beffcc2e9c..61fec08868 100644 --- a/packages/backend/src/core/UserFollowingService.ts +++ b/packages/backend/src/core/UserFollowingService.ts @@ -19,7 +19,13 @@ import { FederatedInstanceService } from '@/core/FederatedInstanceService.js'; import { WebhookService } from '@/core/WebhookService.js'; import { NotificationService } from '@/core/NotificationService.js'; import { DI } from '@/di-symbols.js'; -import type { FollowingsRepository, FollowRequestsRepository, InstancesRepository, UserProfilesRepository, UsersRepository } from '@/models/_.js'; +import type { + FollowingsRepository, + FollowRequestsRepository, + InstancesRepository, + UserProfilesRepository, + UsersRepository, +} from '@/models/_.js'; import { UserEntityService } from '@/core/entities/UserEntityService.js'; import { ApRendererService } from '@/core/activitypub/ApRendererService.js'; import { bindThis } from '@/decorators.js'; @@ -51,25 +57,18 @@ export class UserFollowingService implements OnModuleInit { constructor( private moduleRef: ModuleRef, - @Inject(DI.config) private config: Config, - @Inject(DI.usersRepository) private usersRepository: UsersRepository, - @Inject(DI.userProfilesRepository) private userProfilesRepository: UserProfilesRepository, - @Inject(DI.followingsRepository) private followingsRepository: FollowingsRepository, - @Inject(DI.followRequestsRepository) private followRequestsRepository: FollowRequestsRepository, - @Inject(DI.instancesRepository) private instancesRepository: InstancesRepository, - private cacheService: CacheService, private userEntityService: UserEntityService, private idService: IdService, @@ -91,7 +90,9 @@ export class UserFollowingService implements OnModuleInit { } @bindThis - public async follow(_follower: { id: MiUser['id'] }, _followee: { id: MiUser['id'] }, requestId?: string, silent = false): Promise { + public async follow(_follower: { id: MiUser['id'] }, _followee: { + id: MiUser['id'] + }, requestId?: string, silent = false): Promise { const [follower, followee] = await Promise.all([ this.usersRepository.findOneByOrFail({ id: _follower.id }), this.usersRepository.findOneByOrFail({ id: _followee.id }), @@ -184,10 +185,18 @@ export class UserFollowingService implements OnModuleInit { @bindThis private async insertFollowingDoc( followee: { - id: MiUser['id']; host: MiUser['host']; uri: MiUser['host']; inbox: MiUser['inbox']; sharedInbox: MiUser['sharedInbox'] + id: MiUser['id']; + host: MiUser['host']; + uri: MiUser['host']; + inbox: MiUser['inbox']; + sharedInbox: MiUser['sharedInbox'] }, follower: { - id: MiUser['id']; host: MiUser['host']; uri: MiUser['host']; inbox: MiUser['inbox']; sharedInbox: MiUser['sharedInbox'] + id: MiUser['id']; + host: MiUser['host']; + uri: MiUser['host']; + inbox: MiUser['inbox']; + sharedInbox: MiUser['sharedInbox'] }, silent = false, ): Promise { @@ -233,8 +242,7 @@ export class UserFollowingService implements OnModuleInit { }); // 通知を作成 - this.notificationService.createNotification(follower.id, 'followRequestAccepted', { - }, followee.id); + this.notificationService.createNotification(follower.id, 'followRequestAccepted', {}, followee.id); } if (alreadyFollowed) return; @@ -306,18 +314,25 @@ export class UserFollowingService implements OnModuleInit { }); // 通知を作成 - this.notificationService.createNotification(followee.id, 'follow', { - }, follower.id); + this.notificationService.createNotification(followee.id, 'follow', {}, follower.id); } } @bindThis public async unfollow( follower: { - id: MiUser['id']; host: MiUser['host']; uri: MiUser['host']; inbox: MiUser['inbox']; sharedInbox: MiUser['sharedInbox']; + id: MiUser['id']; + host: MiUser['host']; + uri: MiUser['host']; + inbox: MiUser['inbox']; + sharedInbox: MiUser['sharedInbox']; }, followee: { - id: MiUser['id']; host: MiUser['host']; uri: MiUser['host']; inbox: MiUser['inbox']; sharedInbox: MiUser['sharedInbox']; + id: MiUser['id']; + host: MiUser['host']; + uri: MiUser['host']; + inbox: MiUser['inbox']; + sharedInbox: MiUser['sharedInbox']; }, silent = false, ): Promise { @@ -446,10 +461,18 @@ export class UserFollowingService implements OnModuleInit { @bindThis public async createFollowRequest( follower: { - id: MiUser['id']; host: MiUser['host']; uri: MiUser['host']; inbox: MiUser['inbox']; sharedInbox: MiUser['sharedInbox']; + id: MiUser['id']; + host: MiUser['host']; + uri: MiUser['host']; + inbox: MiUser['inbox']; + sharedInbox: MiUser['sharedInbox']; }, followee: { - id: MiUser['id']; host: MiUser['host']; uri: MiUser['host']; inbox: MiUser['inbox']; sharedInbox: MiUser['sharedInbox']; + id: MiUser['id']; + host: MiUser['host']; + uri: MiUser['host']; + inbox: MiUser['inbox']; + sharedInbox: MiUser['sharedInbox']; }, requestId?: string, ): Promise { @@ -541,7 +564,11 @@ export class UserFollowingService implements OnModuleInit { @bindThis public async acceptFollowRequest( followee: { - id: MiUser['id']; host: MiUser['host']; uri: MiUser['host']; inbox: MiUser['inbox']; sharedInbox: MiUser['sharedInbox']; + id: MiUser['id']; + host: MiUser['host']; + uri: MiUser['host']; + inbox: MiUser['inbox']; + sharedInbox: MiUser['sharedInbox']; }, follower: MiUser, ): Promise { @@ -569,7 +596,11 @@ export class UserFollowingService implements OnModuleInit { @bindThis public async acceptAllFollowRequests( user: { - id: MiUser['id']; host: MiUser['host']; uri: MiUser['host']; inbox: MiUser['inbox']; sharedInbox: MiUser['sharedInbox']; + id: MiUser['id']; + host: MiUser['host']; + uri: MiUser['host']; + inbox: MiUser['inbox']; + sharedInbox: MiUser['sharedInbox']; }, ): Promise { const requests = await this.followRequestsRepository.findBy({ diff --git a/packages/backend/src/server/api/endpoints/admin/emoji/add-draft.ts b/packages/backend/src/server/api/endpoints/admin/emoji/add-draft.ts index 0ed69d335a..7088f801e9 100644 --- a/packages/backend/src/server/api/endpoints/admin/emoji/add-draft.ts +++ b/packages/backend/src/server/api/endpoints/admin/emoji/add-draft.ts @@ -1,6 +1,6 @@ import { Inject, Injectable } from '@nestjs/common'; - import { Endpoint } from '@/server/api/endpoint-base.js'; -import type { DriveFilesRepository } from '@/models/index.js'; +import { Endpoint } from '@/server/api/endpoint-base.js'; +import type { DriveFilesRepository } from '@/models/_.js'; import { DI } from '@/di-symbols.js'; import { CustomEmojiService } from '@/core/CustomEmojiService.js'; import { ModerationLogService } from '@/core/ModerationLogService.js'; diff --git a/packages/backend/src/server/api/endpoints/admin/emoji/add.ts b/packages/backend/src/server/api/endpoints/admin/emoji/add.ts index 5e1b0e345c..7f4474419c 100644 --- a/packages/backend/src/server/api/endpoints/admin/emoji/add.ts +++ b/packages/backend/src/server/api/endpoints/admin/emoji/add.ts @@ -41,17 +41,21 @@ export const paramDef = { nullable: true, description: 'Use `null` to reset the category.', }, - aliases: { type: 'array', items: { - type: 'string', - } }, + aliases: { + type: 'array', items: { + type: 'string', + }, + }, license: { type: 'string', nullable: true }, isSensitive: { type: 'boolean' }, localOnly: { type: 'boolean' }, - roleIdsThatCanBeUsedThisEmojiAsReaction: { type: 'array', items: { - type: 'string', - } }, + roleIdsThatCanBeUsedThisEmojiAsReaction: { + type: 'array', items: { + type: 'string', + }, + }, }, - required: ['name','fileId', 'draft'], + required: ['name', 'fileId', 'draft'], } as const; // TODO: ロジックをサービスに切り出す @@ -61,9 +65,7 @@ export default class extends Endpoint { // eslint- constructor( @Inject(DI.driveFilesRepository) private driveFilesRepository: DriveFilesRepository, - private customEmojiService: CustomEmojiService, - private emojiEntityService: EmojiEntityService, ) { super(meta, paramDef, async (ps, me) => { @@ -82,7 +84,7 @@ export default class extends Endpoint { // eslint- license: ps.license ?? null, isSensitive: ps.isSensitive ?? false, localOnly: ps.localOnly ?? false, - draft: false, + draft: false, roleIdsThatCanBeUsedThisEmojiAsReaction: ps.roleIdsThatCanBeUsedThisEmojiAsReaction ?? [], }, me); diff --git a/packages/backend/src/server/api/endpoints/admin/emoji/update.ts b/packages/backend/src/server/api/endpoints/admin/emoji/update.ts index 7519f2d33e..595dd12964 100644 --- a/packages/backend/src/server/api/endpoints/admin/emoji/update.ts +++ b/packages/backend/src/server/api/endpoints/admin/emoji/update.ts @@ -57,7 +57,7 @@ export const paramDef = { } }, draft: { type: 'boolean' }, }, - required: ['id', 'name', 'aliases'], + required: ['id', 'name', 'draft', 'aliases'], } as const; @Injectable() @@ -94,7 +94,7 @@ export default class extends Endpoint { // eslint- isSensitive: ps.isSensitive, localOnly: ps.localOnly, roleIdsThatCanBeUsedThisEmojiAsReaction: ps.roleIdsThatCanBeUsedThisEmojiAsReaction, - draft: ps.draft, + draft: ps.draft, }, me); }); } diff --git a/packages/frontend/src/components/MkEmojiEditDialog.vue b/packages/frontend/src/components/MkEmojiEditDialog.vue index 5a337249dd..5490fed3ee 100644 --- a/packages/frontend/src/components/MkEmojiEditDialog.vue +++ b/packages/frontend/src/components/MkEmojiEditDialog.vue @@ -7,7 +7,7 @@ SPDX-License-Identifier: AGPL-3.0-only @@ -51,7 +51,7 @@ SPDX-License-Identifier: AGPL-3.0-only -
+
{{ i18n.ts.add }}
@@ -73,19 +73,19 @@ SPDX-License-Identifier: AGPL-3.0-only
- {{ i18n.ts.delete }} + {{ i18n.ts.delete }} {{ props.emoji ? i18n.ts.update : i18n.ts.create }} {{ props.emoji ? i18n.ts.update : i18n.ts.create }}
- -
+
diff --git a/packages/frontend/src/pages/about.federation.vue b/packages/frontend/src/pages/about.federation.vue index 2aa5af939b..4d8c51239f 100644 --- a/packages/frontend/src/pages/about.federation.vue +++ b/packages/frontend/src/pages/about.federation.vue @@ -41,7 +41,10 @@ SPDX-License-Identifier: AGPL-3.0-only
- +
diff --git a/packages/frontend/src/pages/admin/instance-block.vue b/packages/frontend/src/pages/admin/instance-block.vue index 9a0f5e026b..b82e425682 100644 --- a/packages/frontend/src/pages/admin/instance-block.vue +++ b/packages/frontend/src/pages/admin/instance-block.vue @@ -5,7 +5,9 @@ SPDX-License-Identifier: AGPL-3.0-only