diff options
| author | おさむのひと <46447427+samunohito@users.noreply.github.com> | 2025-04-13 20:48:18 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-13 20:48:18 +0900 |
| commit | 0d4feed6d3198a160850cf8c04613a771c66a4a6 (patch) | |
| tree | 32b0dade78e25c6fe5df779b67071764707d8d56 /packages/backend/src/core/AntennaService.ts | |
| parent | レプリケーション設定時におけるinsertOne()の挙動を調整 (#... (diff) | |
| download | sharkey-0d4feed6d3198a160850cf8c04613a771c66a4a6.tar.gz sharkey-0d4feed6d3198a160850cf8c04613a771c66a4a6.tar.bz2 sharkey-0d4feed6d3198a160850cf8c04613a771c66a4a6.zip | |
enhance(backend): フォローしているユーザーならフォロワー限定投稿のノートでもアンテナで検知できるように (#15264)
* フォローしているユーザーなら鍵ノートでもアンテナにひっかかるように
Co-authored-by: kozakura913 <98575220+kozakura913@users.noreply.github.com>
Co-authored-by: mai <74494945+chan-mai@users.noreply.github.com>
* Eliminate build errors by resolving conflicts
* 低コストな判定文を前にもってきて重い判定文に入る可能性を少しでも下げる
* fix CHANGELOG.md
* fix CHANGELOG.md
* fix diff
* removed comment
* fix CHANGELOG.md
---------
Co-authored-by: kozakura913 <98575220+kozakura913@users.noreply.github.com>
Co-authored-by: mai <74494945+chan-mai@users.noreply.github.com>
Co-authored-by: syuilo <4439005+syuilo@users.noreply.github.com>
Diffstat (limited to 'packages/backend/src/core/AntennaService.ts')
| -rw-r--r-- | packages/backend/src/core/AntennaService.ts | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/packages/backend/src/core/AntennaService.ts b/packages/backend/src/core/AntennaService.ts index 828cf4f706..7db3e69155 100644 --- a/packages/backend/src/core/AntennaService.ts +++ b/packages/backend/src/core/AntennaService.ts @@ -5,18 +5,19 @@ import { Inject, Injectable } from '@nestjs/common'; import * as Redis from 'ioredis'; -import type { MiAntenna } from '@/models/Antenna.js'; -import type { MiNote } from '@/models/Note.js'; -import type { MiUser } from '@/models/User.js'; +import { FanoutTimelineService } from '@/core/FanoutTimelineService.js'; +import type { GlobalEvents } from '@/core/GlobalEventService.js'; import { GlobalEventService } from '@/core/GlobalEventService.js'; +import { UtilityService } from '@/core/UtilityService.js'; +import { bindThis } from '@/decorators.js'; +import { DI } from '@/di-symbols.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, UserListMembershipsRepository } 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 type { MiAntenna } from '@/models/Antenna.js'; +import type { MiNote } from '@/models/Note.js'; +import type { MiUser } from '@/models/User.js'; +import { CacheService } from './CacheService.js'; import type { OnApplicationShutdown } from '@nestjs/common'; @Injectable() @@ -37,6 +38,7 @@ export class AntennaService implements OnApplicationShutdown { @Inject(DI.userListMembershipsRepository) private userListMembershipsRepository: UserListMembershipsRepository, + private cacheService: CacheService, private utilityService: UtilityService, private globalEventService: GlobalEventService, private fanoutTimelineService: FanoutTimelineService, @@ -111,9 +113,6 @@ 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<boolean> { - if (note.visibility === 'specified') return false; - if (note.visibility === 'followers') return false; - if (antenna.excludeNotesInSensitiveChannel && note.channel?.isSensitive) return false; if (antenna.excludeBots && noteUser.isBot) return false; @@ -122,6 +121,18 @@ export class AntennaService implements OnApplicationShutdown { if (!antenna.withReplies && note.replyId != null) 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.src === 'home') { // TODO } else if (antenna.src === 'list') { |