From bb54909d8efb0a40247ee9ca9138f60f7a86b8c0 Mon Sep 17 00:00:00 2001 From: Mar0xy Date: Wed, 18 Oct 2023 19:51:10 +0200 Subject: [PATCH] upd: filter fallback to db for silenced users --- .../src/server/api/endpoints/notes/hybrid-timeline.ts | 9 +++++++-- .../src/server/api/endpoints/notes/local-timeline.ts | 7 ++++++- .../backend/src/server/api/endpoints/notes/timeline.ts | 7 ++++++- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/packages/backend/src/server/api/endpoints/notes/hybrid-timeline.ts b/packages/backend/src/server/api/endpoints/notes/hybrid-timeline.ts index 8e59ea4bcc..ada88ea4f2 100644 --- a/packages/backend/src/server/api/endpoints/notes/hybrid-timeline.ts +++ b/packages/backend/src/server/api/endpoints/notes/hybrid-timeline.ts @@ -185,7 +185,7 @@ export default class extends Endpoint { // eslint- .leftJoinAndSelect('note.renote', 'renote') .leftJoinAndSelect('reply.user', 'replyUser') .leftJoinAndSelect('renote.user', 'renoteUser'); - + if (!ps.withBots) query.andWhere('user.isBot = FALSE'); query.andWhere(new Brackets(qb => { @@ -238,7 +238,12 @@ export default class extends Endpoint { // eslint- } //#endregion - const timeline = await query.limit(ps.limit).getMany(); + let timeline = await query.limit(ps.limit).getMany(); + + timeline = timeline.filter(note => { + if (note.user?.isSilenced && note.userId !== me.id && !followings[note.userId]) return false; + return true; + }); process.nextTick(() => { this.activeUsersChart.read(me); diff --git a/packages/backend/src/server/api/endpoints/notes/local-timeline.ts b/packages/backend/src/server/api/endpoints/notes/local-timeline.ts index 1d3241c55f..85560f12ca 100644 --- a/packages/backend/src/server/api/endpoints/notes/local-timeline.ts +++ b/packages/backend/src/server/api/endpoints/notes/local-timeline.ts @@ -171,7 +171,12 @@ export default class extends Endpoint { // eslint- query.andWhere('note.fileIds != \'{}\''); } - const timeline = await query.limit(ps.limit).getMany(); + let timeline = await query.limit(ps.limit).getMany(); + + timeline = timeline.filter(note => { + if (note.user?.isSilenced && me && followings && note.userId !== me.id && !followings[note.userId]) return false; + return true; + }); process.nextTick(() => { if (me) { diff --git a/packages/backend/src/server/api/endpoints/notes/timeline.ts b/packages/backend/src/server/api/endpoints/notes/timeline.ts index f6de662975..b98d1d9f91 100644 --- a/packages/backend/src/server/api/endpoints/notes/timeline.ts +++ b/packages/backend/src/server/api/endpoints/notes/timeline.ts @@ -199,7 +199,12 @@ export default class extends Endpoint { // eslint- } //#endregion - const timeline = await query.limit(ps.limit).getMany(); + let timeline = await query.limit(ps.limit).getMany(); + + timeline = timeline.filter(note => { + if (note.user?.isSilenced && note.userId !== me.id && !followings[note.userId]) return false; + return true; + }); process.nextTick(() => { this.activeUsersChart.read(me);