summaryrefslogtreecommitdiff
path: root/packages/backend/src/server/api/endpoints/notes
diff options
context:
space:
mode:
authorおさむのひと <46447427+samunohito@users.noreply.github.com>2023-12-03 20:46:19 +0900
committerGitHub <noreply@github.com>2023-12-03 20:46:19 +0900
commit55c8ec80edb275f1477ab8e39274d7c8599b7a8d (patch)
treee0db2cbe1313cee70b417c0f8b76b6bb2cb4bfa1 /packages/backend/src/server/api/endpoints/notes
parent入力フォームでもリアクション選択時に使用するピッカ... (diff)
downloadsharkey-55c8ec80edb275f1477ab8e39274d7c8599b7a8d.tar.gz
sharkey-55c8ec80edb275f1477ab8e39274d7c8599b7a8d.tar.bz2
sharkey-55c8ec80edb275f1477ab8e39274d7c8599b7a8d.zip
fix (backend): 「みつける」のなかにミュートしたユーザが現れてしまう問題を修正 (#12559)
* fix (backend): 「みつける」のなかにミュートしたユーザが現れてしまう問題を修正 * fix
Diffstat (limited to 'packages/backend/src/server/api/endpoints/notes')
-rw-r--r--packages/backend/src/server/api/endpoints/notes/featured.ts21
1 files changed, 18 insertions, 3 deletions
diff --git a/packages/backend/src/server/api/endpoints/notes/featured.ts b/packages/backend/src/server/api/endpoints/notes/featured.ts
index bc6cbe242f..31b8d1ad2d 100644
--- a/packages/backend/src/server/api/endpoints/notes/featured.ts
+++ b/packages/backend/src/server/api/endpoints/notes/featured.ts
@@ -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'],
@@ -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,
) {
@@ -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')
@@ -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);
});