fix(filter): relation check

This commit is contained in:
オスカー、 2024-09-06 17:58:02 +09:00
parent ba95b99abc
commit 92f7f90a5c
Signed by: SWREI
GPG Key ID: 139D6573F92DA9F7
2 changed files with 8 additions and 3 deletions

View File

@ -132,15 +132,19 @@ export class AntennaService implements OnApplicationShutdown {
private async filter(me: MiUser | null, note: (MiNote | Packed<'Note'>)): Promise<boolean> {
const [
userIdsWhoMeMuting,
userIdsWhoMeBlocking,
userIdsWhoBlockingMe,
] = me ? await Promise.all([
this.cacheService.userMutingsCache.fetch(me.id),
this.cacheService.userBlockingCache.fetch(me.id),
this.cacheService.userBlockedCache.fetch(me.id),
]) : [new Set<string>(), new Set<string>()];
]) : [new Set<string>(), new Set<string>(), new Set<string>()];
if (me && isUserRelated(note, userIdsWhoBlockingMe)) return false;
if (me && isUserRelated(note, userIdsWhoMeBlocking)) return false;
if (me && isUserRelated(note, userIdsWhoMeMuting)) return false;
if (['followers', 'specified'].includes(note.visibility)) {
if (!me) return false;
if (me == null) return false;
if (me.id === note.userId) return true;
if (note.visibility === 'followers') {
const relationship = await this.userEntityService.getRelation(me.id, note.userId);
if (relationship.isFollowing) return true;
@ -153,7 +157,7 @@ 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> {
const result = await this.filter(antenna.user, note);
if (!result && antenna.userId !== note.userId) return false;
if (!result) return false;
if (antenna.excludeBots && noteUser.isBot) return false;

View File

@ -280,6 +280,7 @@ export class SearchService {
if (me && isUserRelated(note, userIdsWhoMeMuting)) return false;
if (['followers', 'specified'].includes(note.visibility)) {
if (me == null) return false;
if (me.id === note.userId) return true;
if (note.visibility === 'followers') {
const relationship = await this.userEntityService.getRelation(me.id, note.userId);
if (relationship.isFollowing) return true;