フォローしているユーザーなら鍵ノートでもアンテナにひっかかるように

Co-authored-by: kozakura913 <98575220+kozakura913@users.noreply.github.com>
Co-authored-by: mai <74494945+chan-mai@users.noreply.github.com>
This commit is contained in:
kozakura913 2024-12-27 01:48:43 +09:00 committed by おさむのひと
parent d60c307c4e
commit 742e689163
2 changed files with 30 additions and 5 deletions

View File

@ -37,6 +37,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,
@ -111,8 +115,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<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 = 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;

View File

@ -373,13 +373,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<Note> => post(userFollowedByAlice, { text: `${keyword}`, visibility: 'public' }), included: true },
{ note: (): Promise<Note> => post(userFollowedByAlice, { text: `${keyword}`, visibility: 'home' }), included: true },
{ note: (): Promise<Note> => post(userFollowedByAlice, { text: `${keyword}`, visibility: 'followers' }) },
{ note: (): Promise<Note> => post(userFollowedByAlice, { text: `${keyword}`, visibility: 'specified', visibleUserIds: [alice.id] }) },
{ note: (): Promise<Note> => post(userFollowedByAlice, { text: `${keyword}`, visibility: 'followers' }), included: true },
{ note: (): Promise<Note> => 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<Note> => post(bob, { text: `${keyword}`, visibility: 'public' }), included: true },
{ note: (): Promise<Note> => post(bob, { text: `${keyword}`, visibility: 'home' }), included: true },
{ note: (): Promise<Note> => post(bob, { text: `${keyword}`, visibility: 'followers' }) },
{ note: (): Promise<Note> => post(bob, { text: `${keyword}`, visibility: 'specified', visibleUserIds: [carol.id] }) },
],
},
{