From 387fcd5c5df04a461f346781bf5621d343b15e66 Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 1 Feb 2023 17:29:28 +0900 Subject: [PATCH] refactor: fix type --- packages/backend/src/core/NoteReadService.ts | 10 ++-------- .../backend/src/misc/extract-custom-emojis-from-mfm.ts | 2 +- packages/backend/src/misc/extract-hashtags.ts | 2 +- .../src/server/api/integration/DiscordServerService.ts | 2 +- .../src/server/api/integration/GithubServerService.ts | 2 +- 5 files changed, 6 insertions(+), 12 deletions(-) diff --git a/packages/backend/src/core/NoteReadService.ts b/packages/backend/src/core/NoteReadService.ts index 82825b8b15..f4395725d6 100644 --- a/packages/backend/src/core/NoteReadService.ts +++ b/packages/backend/src/core/NoteReadService.ts @@ -9,9 +9,9 @@ import { IdService } from '@/core/IdService.js'; import { GlobalEventService } from '@/core/GlobalEventService.js'; import type { UsersRepository, NoteUnreadsRepository, MutingsRepository, NoteThreadMutingsRepository, FollowingsRepository, ChannelFollowingsRepository, AntennaNotesRepository } from '@/models/index.js'; import { UserEntityService } from '@/core/entities/UserEntityService.js'; +import { bindThis } from '@/decorators.js'; import { NotificationService } from './NotificationService.js'; import { AntennaService } from './AntennaService.js'; -import { bindThis } from '@/decorators.js'; import { PushNotificationService } from './PushNotificationService.js'; @Injectable() @@ -107,12 +107,6 @@ export class NoteReadService { followingChannels: Set; }, ): Promise { - const following = info?.following ? info.following : new Set((await this.followingsRepository.find({ - where: { - followerId: userId, - }, - select: ['followeeId'], - })).map(x => x.followeeId)); const followingChannels = info?.followingChannels ? info.followingChannels : new Set((await this.channelFollowingsRepository.find({ where: { followerId: userId, @@ -139,7 +133,7 @@ export class NoteReadService { if (note.user != null) { // たぶんnullになることは無いはずだけど一応 for (const antenna of myAntennas) { - if (await this.antennaService.checkHitAntenna(antenna, note, note.user, undefined, Array.from(following))) { + if (await this.antennaService.checkHitAntenna(antenna, note, note.user)) { readAntennaNotes.push(note); } } diff --git a/packages/backend/src/misc/extract-custom-emojis-from-mfm.ts b/packages/backend/src/misc/extract-custom-emojis-from-mfm.ts index 8fb3f4b19e..14c25922ad 100644 --- a/packages/backend/src/misc/extract-custom-emojis-from-mfm.ts +++ b/packages/backend/src/misc/extract-custom-emojis-from-mfm.ts @@ -4,7 +4,7 @@ import { unique } from '@/misc/prelude/array.js'; export function extractCustomEmojisFromMfm(nodes: mfm.MfmNode[]): string[] { const emojiNodes = mfm.extract(nodes, (node) => { return (node.type === 'emojiCode' && node.props.name.length <= 100); - }); + }) as mfm.MfmEmojiCode[]; return unique(emojiNodes.map(x => x.props.name)); } diff --git a/packages/backend/src/misc/extract-hashtags.ts b/packages/backend/src/misc/extract-hashtags.ts index f8cabda3d6..d293fd7f52 100644 --- a/packages/backend/src/misc/extract-hashtags.ts +++ b/packages/backend/src/misc/extract-hashtags.ts @@ -2,7 +2,7 @@ import * as mfm from 'mfm-js'; import { unique } from '@/misc/prelude/array.js'; export function extractHashtags(nodes: mfm.MfmNode[]): string[] { - const hashtagNodes = mfm.extract(nodes, (node) => node.type === 'hashtag'); + const hashtagNodes = mfm.extract(nodes, (node) => node.type === 'hashtag') as mfm.MfmHashtag[]; const hashtags = unique(hashtagNodes.map(x => x.props.hashtag)); return hashtags; diff --git a/packages/backend/src/server/api/integration/DiscordServerService.ts b/packages/backend/src/server/api/integration/DiscordServerService.ts index 0ac2733817..cbced901e4 100644 --- a/packages/backend/src/server/api/integration/DiscordServerService.ts +++ b/packages/backend/src/server/api/integration/DiscordServerService.ts @@ -134,7 +134,7 @@ export class DiscordServerService { reply.redirect(oauth2!.getAuthorizeUrl(params)); }); - fastify.get('/dc/cb', async (request, reply) => { + fastify.get<{ Querystring: { code: string; state: string; } }>('/dc/cb', async (request, reply) => { const userToken = this.getUserToken(request); const oauth2 = await getOAuth2(); diff --git a/packages/backend/src/server/api/integration/GithubServerService.ts b/packages/backend/src/server/api/integration/GithubServerService.ts index a8c745d2dc..76089c9359 100644 --- a/packages/backend/src/server/api/integration/GithubServerService.ts +++ b/packages/backend/src/server/api/integration/GithubServerService.ts @@ -132,7 +132,7 @@ export class GithubServerService { reply.redirect(oauth2!.getAuthorizeUrl(params)); }); - fastify.get('/gh/cb', async (request, reply) => { + fastify.get<{ Querystring: { code: string; state: string; } }>('/gh/cb', async (request, reply) => { const userToken = this.getUserToken(request); const oauth2 = await getOath2();