Skip to content

Commit

Permalink
userFollowingsCache
Browse files Browse the repository at this point in the history
  • Loading branch information
kozakura913 committed Dec 20, 2024
1 parent ebab636 commit cfadcc9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG_YOJO.md
Original file line number Diff line number Diff line change
@@ -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.0
Cherrypick 4.13.0
Misskey 2024.10.1
Expand Down
10 changes: 3 additions & 7 deletions packages/backend/src/core/AntennaService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ 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';

Expand Down Expand Up @@ -44,6 +45,7 @@ export class AntennaService implements OnApplicationShutdown {
@Inject(DI.followingsRepository)
private followingsRepository: FollowingsRepository,

private cacheService: CacheService,
private utilityService: UtilityService,
private globalEventService: GlobalEventService,
private fanoutTimelineService: FanoutTimelineService,
Expand Down Expand Up @@ -109,13 +111,7 @@ export class AntennaService implements OnApplicationShutdown {
}
}
if (note.visibility === 'followers') {
const isFollowing = await this.followingsRepository.count({
where: {
followerId: antenna.userId,
followeeId: note.userId,
},
take: 1,
}).then(n => n > 0);
const isFollowing = Object.hasOwn(await this.cacheService.userFollowingsCache.fetch(antenna.userId), note.userId);
if (!isFollowing && antenna.userId !== note.userId) return false;
}

Expand Down

0 comments on commit cfadcc9

Please sign in to comment.