From a56c680136b50166347da97e475fdf5b446f8e94 Mon Sep 17 00:00:00 2001 From: samunohito <46447427+samunohito@users.noreply.github.com> Date: Wed, 12 Jun 2024 06:59:53 +0900 Subject: [PATCH] =?UTF-8?q?TL=E3=81=AE=E6=8A=BD=E5=87=BA=E6=9D=A1=E4=BB=B6?= =?UTF-8?q?=E8=AA=BF=E7=AF=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/endpoints/notes/hybrid-timeline.ts | 27 ++++++++++++------- .../server/api/endpoints/notes/timeline.ts | 23 +++++++++++----- 2 files changed, 35 insertions(+), 15 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 f6a7aa1c6c..af92ae4849 100644 --- a/packages/backend/src/server/api/endpoints/notes/hybrid-timeline.ts +++ b/packages/backend/src/server/api/endpoints/notes/hybrid-timeline.ts @@ -5,7 +5,7 @@ import { Brackets } from 'typeorm'; import { Inject, Injectable } from '@nestjs/common'; -import type { NotesRepository, ChannelFollowingsRepository } from '@/models/_.js'; +import type { ChannelFollowingsRepository, NotesRepository } from '@/models/_.js'; import { Endpoint } from '@/server/api/endpoint-base.js'; import ActiveUsersChart from '@/core/chart/charts/active-users.js'; import { NoteEntityService } from '@/core/entities/NoteEntityService.js'; @@ -77,10 +77,8 @@ export default class extends Endpoint { // eslint- constructor( @Inject(DI.notesRepository) private notesRepository: NotesRepository, - @Inject(DI.channelFollowingsRepository) private channelFollowingsRepository: ChannelFollowingsRepository, - private noteEntityService: NoteEntityService, private roleService: RoleService, private activeUsersChart: ActiveUsersChart, @@ -191,9 +189,7 @@ export default class extends Endpoint { // eslint- followerId: me.id, }, }); - const mutingChannelIds = (followingChannels.length > 0) - ? await this.channelMutingService.list({ requestUserId: me.id }).then(x => x.map(x => x.id)) - : []; + const mutingChannelIds = await this.channelMutingService.list({ requestUserId: me.id }).then(x => x.map(x => x.id)); const query = this.queryService.makePaginationQuery(this.notesRepository.createQueryBuilder('note'), ps.sinceId, ps.untilId) .andWhere(new Brackets(qb => { @@ -224,11 +220,24 @@ export default class extends Endpoint { // eslint- } if (mutingChannelIds.length > 0) { - // ミュートしてるチャンネルは含めない query.andWhere(new Brackets(qb => { qb - .andWhere('note.channelId NOT IN (:...mutingChannelIds)', { mutingChannelIds }) - .andWhere('note.renoteChannelId NOT IN (:...mutingChannelIds)', { mutingChannelIds }); + // ミュートしてるチャンネルは含めない + .where(new Brackets(qb2 => { + qb2 + .andWhere(new Brackets(qb3 => { + qb3 + .andWhere('note.channelId IS NOT NULL') + .andWhere('note.channelId NOT IN (:...mutingChannelIds)', { mutingChannelIds }); + })) + .andWhere(new Brackets(qb3 => { + qb3 + .andWhere('note.renoteChannelId IS NOT NULL') + .andWhere('note.renoteChannelId NOT IN (:...mutingChannelIds)', { mutingChannelIds }); + })); + })) + // チャンネルの投稿ではない + .orWhere('note.channelId IS NULL'); })); } diff --git a/packages/backend/src/server/api/endpoints/notes/timeline.ts b/packages/backend/src/server/api/endpoints/notes/timeline.ts index 9fa9abc903..38b27da1ed 100644 --- a/packages/backend/src/server/api/endpoints/notes/timeline.ts +++ b/packages/backend/src/server/api/endpoints/notes/timeline.ts @@ -149,9 +149,7 @@ export default class extends Endpoint { // eslint- followerId: me.id, }, }); - const mutingChannelIds = (followingChannels.length > 0) - ? await this.channelMutingService.list({ requestUserId: me.id }).then(x => x.map(x => x.id)) - : []; + const mutingChannelIds = await this.channelMutingService.list({ requestUserId: me.id }).then(x => x.map(x => x.id)); //#region Construct query const query = this.queryService.makePaginationQuery(this.notesRepository.createQueryBuilder('note'), ps.sinceId, ps.untilId) @@ -200,11 +198,24 @@ export default class extends Endpoint { // eslint- } if (mutingChannelIds.length > 0) { - // ミュートしてるチャンネルは含めない query.andWhere(new Brackets(qb => { qb - .andWhere('note.channelId NOT IN (:...mutingChannelIds)', { mutingChannelIds }) - .andWhere('note.renoteChannelId NOT IN (:...mutingChannelIds)', { mutingChannelIds }); + // ミュートしてるチャンネルは含めない + .where(new Brackets(qb2 => { + qb2 + .andWhere(new Brackets(qb3 => { + qb3 + .andWhere('note.channelId IS NOT NULL') + .andWhere('note.channelId NOT IN (:...mutingChannelIds)', { mutingChannelIds }); + })) + .andWhere(new Brackets(qb3 => { + qb3 + .andWhere('note.renoteChannelId IS NOT NULL') + .andWhere('note.renoteChannelId NOT IN (:...mutingChannelIds)', { mutingChannelIds }); + })); + })) + // チャンネルの投稿ではない + .orWhere('note.channelId IS NULL'); })); }