From 140dfdaccc1ad405b2387e5e7b45b28d40c9596e Mon Sep 17 00:00:00 2001 From: mattyatea Date: Tue, 10 Oct 2023 12:38:34 +0900 Subject: [PATCH] bug fix --- .../src/server/api/endpoints/channels/timeline.ts | 6 ++---- .../src/server/api/endpoints/notes/featured.ts | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/packages/backend/src/server/api/endpoints/channels/timeline.ts b/packages/backend/src/server/api/endpoints/channels/timeline.ts index 4385c698eb..1efaef19a3 100644 --- a/packages/backend/src/server/api/endpoints/channels/timeline.ts +++ b/packages/backend/src/server/api/endpoints/channels/timeline.ts @@ -94,7 +94,7 @@ export default class extends Endpoint { // eslint- ] = me ? await Promise.all([ this.cacheService.userMutingsCache.fetch(me.id), ]) : [new Set()]; - + console.log(userIdsWhoMeMuting) let noteIds = await this.redisTimelineService.get(`channelTimeline:${channel.id}`, untilId, sinceId); noteIds = noteIds.slice(0, ps.limit); @@ -111,9 +111,7 @@ export default class extends Endpoint { // eslint- let timeline = await query.getMany(); timeline = timeline.filter(note => { - if (me && isUserRelated(note, userIdsWhoMeMuting, true)) return false; - - return true; + return !isUserRelated(note, userIdsWhoMeMuting); }); // TODO: フィルタで件数が減った場合の埋め合わせ処理 diff --git a/packages/backend/src/server/api/endpoints/notes/featured.ts b/packages/backend/src/server/api/endpoints/notes/featured.ts index c456874309..84e2d4f39b 100644 --- a/packages/backend/src/server/api/endpoints/notes/featured.ts +++ b/packages/backend/src/server/api/endpoints/notes/featured.ts @@ -9,6 +9,9 @@ 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 +50,7 @@ export default class extends Endpoint { // eslint- @Inject(DI.notesRepository) private notesRepository: NotesRepository, + private cacheService: CacheService, private noteEntityService: NoteEntityService, private featuredService: FeaturedService, ) { @@ -63,6 +67,11 @@ export default class extends Endpoint { // eslint- this.globalNotesRankingCacheLastFetchedAt = Date.now(); } } + const [ + userIdsWhoMeMuting, + ] = me ? await Promise.all([ + this.cacheService.userMutingsCache.fetch(me.id), + ]) : [new Set()]; if (noteIds.length === 0) { return []; @@ -83,9 +92,11 @@ export default class extends Endpoint { // eslint- .leftJoinAndSelect('renote.user', 'renoteUser') .leftJoinAndSelect('note.channel', 'channel'); - const notes = await query.getMany(); + let notes = await query.getMany(); notes.sort((a, b) => a.id > b.id ? -1 : 1); - + notes = notes.filter(note => { + return !isUserRelated(note, userIdsWhoMeMuting); + }); // TODO: ミュート等考慮 return await this.noteEntityService.packMany(notes, me);