summaryrefslogtreecommitdiff
path: root/packages/backend/src/server/api/endpoints/roles/notes.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/backend/src/server/api/endpoints/roles/notes.ts')
-rw-r--r--packages/backend/src/server/api/endpoints/roles/notes.ts18
1 files changed, 18 insertions, 0 deletions
diff --git a/packages/backend/src/server/api/endpoints/roles/notes.ts b/packages/backend/src/server/api/endpoints/roles/notes.ts
index e8a760e9f8..4515c016a8 100644
--- a/packages/backend/src/server/api/endpoints/roles/notes.ts
+++ b/packages/backend/src/server/api/endpoints/roles/notes.ts
@@ -5,6 +5,7 @@
import { Inject, Injectable } from '@nestjs/common';
import * as Redis from 'ioredis';
+import { Brackets } from 'typeorm';
import { Endpoint } from '@/server/api/endpoint-base.js';
import type { NotesRepository, RolesRepository } from '@/models/_.js';
import { QueryService } from '@/core/QueryService.js';
@@ -12,6 +13,7 @@ import { DI } from '@/di-symbols.js';
import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
import { IdService } from '@/core/IdService.js';
import { FanoutTimelineService } from '@/core/FanoutTimelineService.js';
+import { ChannelMutingService } from '@/core/ChannelMutingService.js';
import { ApiError } from '../../error.js';
export const meta = {
@@ -68,6 +70,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
private noteEntityService: NoteEntityService,
private queryService: QueryService,
private fanoutTimelineService: FanoutTimelineService,
+ private channelMutingService: ChannelMutingService,
) {
super(meta, paramDef, async (ps, me) => {
const untilId = ps.untilId ?? (ps.untilDate ? this.idService.gen(ps.untilDate!) : null);
@@ -101,6 +104,21 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
.leftJoinAndSelect('reply.user', 'replyUser')
.leftJoinAndSelect('renote.user', 'renoteUser');
+ // -- ミュートされたチャンネル対策
+ const mutingChannelIds = await this.channelMutingService
+ .list({ requestUserId: me.id }, { idOnly: true })
+ .then(x => x.map(x => x.id));
+ if (mutingChannelIds.length > 0) {
+ query.andWhere(new Brackets(qb => {
+ qb.orWhere('note.channelId IS NULL');
+ qb.orWhere('note.channelId NOT IN (:...mutingChannelIds)', { mutingChannelIds });
+ }));
+ query.andWhere(new Brackets(qb => {
+ qb.orWhere('note.renoteChannelId IS NULL');
+ qb.orWhere('note.renoteChannelId NOT IN (:...mutingChannelIds)', { mutingChannelIds });
+ }));
+ }
+
this.queryService.generateVisibilityQuery(query, me);
this.queryService.generateBaseNoteFilteringQuery(query, me);