From 29bd16102f64e56930bc979356b7c62606ea17b0 Mon Sep 17 00:00:00 2001 From: kozakura913 <98575220+kozakura913@users.noreply.github.com> Date: Fri, 27 Dec 2024 01:48:43 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=95=E3=82=A9=E3=83=AD=E3=83=BC=E3=81=97?= =?UTF-8?q?=E3=81=A6=E3=81=84=E3=82=8B=E3=83=A6=E3=83=BC=E3=82=B6=E3=83=BC?= =?UTF-8?q?=E3=81=AA=E3=82=89=E9=8D=B5=E3=83=8E=E3=83=BC=E3=83=88=E3=81=A7?= =?UTF-8?q?=E3=82=82=E3=82=A2=E3=83=B3=E3=83=86=E3=83=8A=E3=81=AB=E3=81=B2?= =?UTF-8?q?=E3=81=A3=E3=81=8B=E3=81=8B=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= =?UTF-8?q?=20(#568)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: mai <74494945+chan-mai@users.noreply.github.com> --- CHANGELOG_YOJO.md | 12 ++++++++++++ packages/backend/src/core/AntennaService.ts | 19 ++++++++++++++++--- packages/backend/test/e2e/antennas.ts | 19 ++++++++++++++++--- 3 files changed, 44 insertions(+), 6 deletions(-) diff --git a/CHANGELOG_YOJO.md b/CHANGELOG_YOJO.md index c178b16b02..5541202e98 100644 --- a/CHANGELOG_YOJO.md +++ b/CHANGELOG_YOJO.md @@ -1,3 +1,15 @@ +## 1.3.0 + +### Release Date + +### General + +### Client + +### Server +- Feat: フォローしているユーザーなら鍵ノートでもアンテナにひっかかるように [#568](https://github.com/yojo-art/cherrypick/pull/568) + - based-on https://github.com/team-shahu/misskey/pull/38 + ## 1.2.2 Cherrypick 4.13.0 Misskey 2024.10.1 diff --git a/packages/backend/src/core/AntennaService.ts b/packages/backend/src/core/AntennaService.ts index 3941a1c87d..5b9e828475 100644 --- a/packages/backend/src/core/AntennaService.ts +++ b/packages/backend/src/core/AntennaService.ts @@ -12,11 +12,12 @@ import { GlobalEventService } from '@/core/GlobalEventService.js'; import * as Acct from '@/misc/acct.js'; import type { Packed } from '@/misc/json-schema.js'; import { DI } from '@/di-symbols.js'; -import type { AntennasRepository, UserGroupJoiningsRepository, UserListMembershipsRepository } from '@/models/_.js'; +import type { AntennasRepository, UserGroupJoiningsRepository, UserListMembershipsRepository, FollowingsRepository } from '@/models/_.js'; import { UtilityService } from '@/core/UtilityService.js'; import { bindThis } from '@/decorators.js'; import type { GlobalEvents } from '@/core/GlobalEventService.js'; import { FanoutTimelineService } from '@/core/FanoutTimelineService.js'; +import { CacheService } from '@/core/CacheService.js'; import { deserializeAntenna } from './deserializeAntenna.js'; import type { OnApplicationShutdown } from '@nestjs/common'; @@ -41,6 +42,10 @@ export class AntennaService implements OnApplicationShutdown { @Inject(DI.userListMembershipsRepository) private userListMembershipsRepository: UserListMembershipsRepository, + @Inject(DI.followingsRepository) + private followingsRepository: FollowingsRepository, + + private cacheService: CacheService, private utilityService: UtilityService, private globalEventService: GlobalEventService, private fanoutTimelineService: FanoutTimelineService, @@ -99,8 +104,16 @@ export class AntennaService implements OnApplicationShutdown { @bindThis public async checkHitAntenna(antenna: MiAntenna, note: (MiNote | Packed<'Note'>), noteUser: { id: MiUser['id']; username: string; host: string | null; isBot: boolean; }): Promise { - if (note.visibility === 'specified') return false; - if (note.visibility === 'followers') return false; + if (note.visibility === 'specified') { + if (note.userId !== antenna.userId) { + if (note.visibleUserIds == null) return false; + if (!note.visibleUserIds.includes(antenna.userId)) return false; + } + } + if (note.visibility === 'followers') { + const isFollowing = Object.hasOwn(await this.cacheService.userFollowingsCache.fetch(antenna.userId), note.userId); + if (!isFollowing && antenna.userId !== note.userId) return false; + } if (antenna.excludeBots && noteUser.isBot) return false; diff --git a/packages/backend/test/e2e/antennas.ts b/packages/backend/test/e2e/antennas.ts index c82b9498cb..210ee9a7a3 100644 --- a/packages/backend/test/e2e/antennas.ts +++ b/packages/backend/test/e2e/antennas.ts @@ -376,13 +376,26 @@ describe('アンテナ', () => { }, { // https://github.com/misskey-dev/misskey/issues/9025 - label: 'ただし、フォロワー限定投稿とDM投稿を含まない。フォロワーであっても。', + // https://github.com/yojo-art/cherrypick/pull/568 + label: 'フォロワー限定投稿とDM投稿を含む', parameters: () => ({}), posts: [ { note: (): Promise => post(userFollowedByAlice, { text: `${keyword}`, visibility: 'public' }), included: true }, { note: (): Promise => post(userFollowedByAlice, { text: `${keyword}`, visibility: 'home' }), included: true }, - { note: (): Promise => post(userFollowedByAlice, { text: `${keyword}`, visibility: 'followers' }) }, - { note: (): Promise => post(userFollowedByAlice, { text: `${keyword}`, visibility: 'specified', visibleUserIds: [alice.id] }) }, + { note: (): Promise => post(userFollowedByAlice, { text: `${keyword}`, visibility: 'followers' }), included: true }, + { note: (): Promise => post(bob, { text: `${keyword}`, visibility: 'specified', visibleUserIds: [alice.id] }), included: true }, + ], + }, + { + // https://github.com/misskey-dev/misskey/issues/9025 + // https://github.com/yojo-art/cherrypick/pull/568 + label: 'フォロワー限定投稿とDM投稿を含まない', + parameters: () => ({}), + posts: [ + { note: (): Promise => post(bob, { text: `${keyword}`, visibility: 'public' }), included: true }, + { note: (): Promise => post(bob, { text: `${keyword}`, visibility: 'home' }), included: true }, + { note: (): Promise => post(bob, { text: `${keyword}`, visibility: 'followers' }) }, + { note: (): Promise => post(bob, { text: `${keyword}`, visibility: 'specified', visibleUserIds: [carol.id] }) }, ], }, {