diff --git a/packages/backend/src/core/entities/ChannelEntityService.ts b/packages/backend/src/core/entities/ChannelEntityService.ts index 71676865c6..bae3d5c117 100644 --- a/packages/backend/src/core/entities/ChannelEntityService.ts +++ b/packages/backend/src/core/entities/ChannelEntityService.ts @@ -8,7 +8,7 @@ import { In } from 'typeorm'; import { DI } from '@/di-symbols.js'; import type { ChannelFavoritesRepository, - ChannelFollowingsRepository, + ChannelFollowingsRepository, ChannelMutingRepository, ChannelsRepository, DriveFilesRepository, MiDriveFile, @@ -33,6 +33,8 @@ export class ChannelEntityService { private channelFollowingsRepository: ChannelFollowingsRepository, @Inject(DI.channelFavoritesRepository) private channelFavoritesRepository: ChannelFavoritesRepository, + @Inject(DI.channelMutingRepository) + private channelMutingRepository: ChannelMutingRepository, @Inject(DI.notesRepository) private notesRepository: NotesRepository, @Inject(DI.driveFilesRepository) @@ -52,6 +54,7 @@ export class ChannelEntityService { bannerFiles?: Map; followings?: Set; favorites?: Set; + muting?: Set; pinnedNotes?: Map; }, ): Promise> { @@ -65,6 +68,7 @@ export class ChannelEntityService { let isFollowing = false; let isFavorite = false; + let isMuting = false; if (me) { isFollowing = opts?.followings?.has(channel.id) ?? await this.channelFollowingsRepository.exists({ where: { @@ -79,6 +83,13 @@ export class ChannelEntityService { channelId: channel.id, }, }); + + isMuting = opts?.muting?.has(channel.id) ?? await this.channelMutingRepository.exists({ + where: { + userId: me.id, + channelId: channel.id, + }, + }); } const pinnedNotes = Array.of(); @@ -112,6 +123,7 @@ export class ChannelEntityService { ...(me ? { isFollowing, isFavorite, + isMuting, hasUnreadNote: false, // 後方互換性のため } : {}), @@ -162,6 +174,15 @@ export class ChannelEntityService { .then(it => new Set(it.map(it => it.channelId))) : new Set(); + const muting = me + ? await this.channelMutingRepository + .findBy({ + userId: me.id, + channelId: In(channels.map(it => it.id)), + }) + .then(it => new Set(it.map(it => it.channelId))) + : new Set(); + const pinnedNotes = await this.notesRepository .find({ where: { @@ -174,6 +195,7 @@ export class ChannelEntityService { bannerFiles, followings, favorites, + muting, pinnedNotes, }))); } diff --git a/packages/backend/src/models/json-schema/channel.ts b/packages/backend/src/models/json-schema/channel.ts index d233f7858d..a7966ffdb3 100644 --- a/packages/backend/src/models/json-schema/channel.ts +++ b/packages/backend/src/models/json-schema/channel.ts @@ -80,6 +80,10 @@ export const packedChannelSchema = { type: 'boolean', optional: true, nullable: false, }, + isMuting: { + type: 'boolean', + optional: true, nullable: false, + }, pinnedNotes: { type: 'array', optional: true, nullable: false, diff --git a/packages/misskey-js/src/autogen/types.ts b/packages/misskey-js/src/autogen/types.ts index 8859667df1..80a68ac8b4 100644 --- a/packages/misskey-js/src/autogen/types.ts +++ b/packages/misskey-js/src/autogen/types.ts @@ -4542,6 +4542,7 @@ export type components = { allowRenoteToExternal: boolean; isFollowing?: boolean; isFavorited?: boolean; + isMuting?: boolean; pinnedNotes?: components['schemas']['Note'][]; }; QueueCount: {