Skip to content

Commit

Permalink
Merge pull request #38 from team-shahu/enhance/antennaservice
Browse files Browse the repository at this point in the history
Enhance/antennaservice
  • Loading branch information
chan-mai authored Nov 6, 2024
2 parents 794c247 + 849ac0b commit fc5096a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
- 誰がリアクションをしたのかを非表示にできる機能 https://github.com/team-shahu/misskey/pull/35 (https://github.com/team-shahu/misskey/commit/5b2923c8127336d7fd2ee39c76d16f8a30d1b9e1)
- 任意のTLを非表示にできるように https://github.com/team-shahu/misskey/pull/36
- プロフィールからアクティビティとファイルを隠せるようにする https://github.com/team-shahu/misskey/pull/37
- フォローしているユーザーなら鍵ノートでもアンテナにひっかかるように https://github.com/team-shahu/misskey/pull/38

## Special Thanks
- [Misskey](https://github.com/misskey-dev/misskey)
Expand Down
23 changes: 20 additions & 3 deletions packages/backend/src/core/AntennaService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ 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, UserListMembershipsRepository } from '@/models/_.js';
import type { AntennasRepository, UserListMembershipsRepository, FollowingsRepository } from '@/models/_.js';
import { UtilityService } from '@/core/UtilityService.js';
import { bindThis } from '@/decorators.js';
import type { GlobalEvents } from '@/core/GlobalEventService.js';
Expand All @@ -37,6 +37,9 @@ export class AntennaService implements OnApplicationShutdown {
@Inject(DI.userListMembershipsRepository)
private userListMembershipsRepository: UserListMembershipsRepository,

@Inject(DI.followingsRepository)
private followingsRepository: FollowingsRepository,

private utilityService: UtilityService,
private globalEventService: GlobalEventService,
private fanoutTimelineService: FanoutTimelineService,
Expand Down Expand Up @@ -111,8 +114,22 @@ 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 (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 = await this.followingsRepository.count({
where: {
followerId: antenna.userId,
followeeId: note.userId,
},
take: 1,
}).then(n => n > 0);
if (!isFollowing && antenna.userId !== note.userId) return false;
}

if (antenna.excludeBots && noteUser.isBot) return false;

Expand Down

0 comments on commit fc5096a

Please sign in to comment.