feat(notes): no blocking user on my note search & etc.

This commit is contained in:
무라쿠모 2024-08-26 17:30:27 +09:00
parent 30c3154737
commit 3891ea6c3f
No known key found for this signature in database
GPG key ID: 139D6573F92DA9F7
10 changed files with 30 additions and 9 deletions

View file

@ -351,15 +351,18 @@ export class SearchService {
if (noteIds.length === 0) return [];
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>()];
const notes = (await this.notesRepository.findBy({
id: In(noteIds),
})).filter(note => {
if (me && isUserRelated(note, userIdsWhoBlockingMe)) return false;
if (me && isUserRelated(note, userIdsWhoMeBlocking)) return false;
if (me && isUserRelated(note, userIdsWhoMeMuting)) return false;
return true;
});
@ -391,8 +394,11 @@ export class SearchService {
}
this.queryService.generateVisibilityQuery(query, me);
if (me) this.queryService.generateMutedUserQuery(query, me);
if (me) this.queryService.generateBlockedUserQuery(query, me);
if (me) {
this.queryService.generateMutedUserQuery(query, me);
this.queryService.generateBlockingUserQuery(query, me);
this.queryService.generateBlockedUserQuery(query, me);
}
return await query.limit(pagination.limit).getMany();
}