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'); })); }