Skip to content

Commit

Permalink
fix (backend): 「みつける」のなかにミュートしたユーザが現れてしまう問題を修正 (#12559)
Browse files Browse the repository at this point in the history
* fix (backend): 「みつける」のなかにミュートしたユーザが現れてしまう問題を修正

* fix
  • Loading branch information
samunohito authored Dec 3, 2023
1 parent 5e1d872 commit 55c8ec8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
- Fix: 特定の条件下でチャンネルやユーザーのノート一覧に最新のノートが表示されなくなる問題を修正
- Fix: 何もノートしていないユーザーのフィードにアクセスするとエラーになる問題を修正
- Fix: リストタイムラインにてミュートが機能しないケースがある問題と、チャンネル投稿がストリーミングで流れてきてしまう問題を修正 #10443
- Fix: 「みつける」のなかにミュートしたユーザが現れてしまう問題を修正 #12383

## 2023.11.1

Expand Down
21 changes: 18 additions & 3 deletions packages/backend/src/server/api/endpoints/notes/featured.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { Endpoint } from '@/server/api/endpoint-base.js';
import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
import { DI } from '@/di-symbols.js';
import { FeaturedService } from '@/core/FeaturedService.js';
import { isUserRelated } from '@/misc/is-user-related.js';
import { CacheService } from '@/core/CacheService.js';

export const meta = {
tags: ['notes'],
Expand Down Expand Up @@ -47,6 +49,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
@Inject(DI.notesRepository)
private notesRepository: NotesRepository,

private cacheService: CacheService,
private noteEntityService: NoteEntityService,
private featuredService: FeaturedService,
) {
Expand Down Expand Up @@ -74,6 +77,14 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
return [];
}

const [
userIdsWhoMeMuting,
userIdsWhoBlockingMe,
] = me ? await Promise.all([
this.cacheService.userMutingsCache.fetch(me.id),
this.cacheService.userBlockedCache.fetch(me.id),
]) : [new Set<string>(), new Set<string>()];

const query = this.notesRepository.createQueryBuilder('note')
.where('note.id IN (:...noteIds)', { noteIds: noteIds })
.innerJoinAndSelect('note.user', 'user')
Expand All @@ -83,10 +94,14 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
.leftJoinAndSelect('renote.user', 'renoteUser')
.leftJoinAndSelect('note.channel', 'channel');

const notes = await query.getMany();
notes.sort((a, b) => a.id > b.id ? -1 : 1);
const notes = (await query.getMany()).filter(note => {
if (me && isUserRelated(note, userIdsWhoBlockingMe)) return false;
if (me && isUserRelated(note, userIdsWhoMeMuting)) return false;

// TODO: ミュート等考慮
return true;
});

notes.sort((a, b) => a.id > b.id ? -1 : 1);

return await this.noteEntityService.packMany(notes, me);
});
Expand Down

0 comments on commit 55c8ec8

Please sign in to comment.