summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorおさむのひと <46447427+samunohito@users.noreply.github.com>2025-11-07 08:39:21 +0900
committerGitHub <noreply@github.com>2025-11-07 08:39:21 +0900
commit729abbef621aea5b8b697644181915935b74bbf8 (patch)
tree27545c0cfd3e6272dd40de2c77daf0d2adec3e6c
parentBump version to 2025.11.0-alpha.1 (diff)
downloadmisskey-729abbef621aea5b8b697644181915935b74bbf8.tar.gz
misskey-729abbef621aea5b8b697644181915935b74bbf8.tar.bz2
misskey-729abbef621aea5b8b697644181915935b74bbf8.zip
feat: チャンネルミュートの実装 (#14105)
* add channel_muting table and entities * add channel_muting services * タイムライン取得処理への組み込み * misskey-jsの型とインターフェース生成 * Channelスキーマにミュート情報を追加 * フロントエンドの実装 * 条件が逆だったのを修正 * 期限切れミュートを掃除する機能を実装 * TLの抽出条件調節 * 名前の変更と変更不要の差分をロールバック * 修正漏れ * isChannelRelatedの条件に誤りがあった * [wip] テスト追加 * テストの追加と検出した不備の修正 * fix test * fix CHANGELOG.md * 通常はFTTにしておく * 実装忘れ対応 * fix merge * fix merge * add channel tl test * fix CHANGELOG.md * remove unused import * fix lint * fix test * fix favorite -> favorited * exclude -> include * fix CHANGELOG.md * fix CHANGELOG.md * maintenance * fix CHANGELOG.md * fix * fix ci * regenerate * fix * Revert "fix" This reverts commit 699d50c6ec798777d8e9667cb5d45a26b06bfc93. * fixed --------- Co-authored-by: syuilo <4439005+syuilo@users.noreply.github.com>
-rw-r--r--CHANGELOG.md2
-rw-r--r--packages/backend/jest.config.unit.cjs1
-rw-r--r--packages/backend/migration/1761569941833-add-channel-muting.js38
-rw-r--r--packages/backend/src/core/ChannelFollowingService.ts48
-rw-r--r--packages/backend/src/core/ChannelMutingService.ts224
-rw-r--r--packages/backend/src/core/CoreModule.ts6
-rw-r--r--packages/backend/src/core/FanoutTimelineEndpointService.ts7
-rw-r--r--packages/backend/src/core/GlobalEventService.ts2
-rw-r--r--packages/backend/src/core/NoteCreateService.ts1
-rw-r--r--packages/backend/src/core/WebhookTestService.ts1
-rw-r--r--packages/backend/src/core/entities/ChannelEntityService.ts156
-rw-r--r--packages/backend/src/di-symbols.ts1
-rw-r--r--packages/backend/src/misc/is-channel-related.ts31
-rw-r--r--packages/backend/src/models/ChannelMuting.ts46
-rw-r--r--packages/backend/src/models/Note.ts8
-rw-r--r--packages/backend/src/models/RepositoryModule.ts9
-rw-r--r--packages/backend/src/models/_.ts3
-rw-r--r--packages/backend/src/models/json-schema/channel.ts4
-rw-r--r--packages/backend/src/postgres.ts2
-rw-r--r--packages/backend/src/queue/processors/CheckExpiredMutingsProcessorService.ts6
-rw-r--r--packages/backend/src/server/api/StreamingApiServerService.ts3
-rw-r--r--packages/backend/src/server/api/endpoint-list.ts3
-rw-r--r--packages/backend/src/server/api/endpoints/antennas/notes.ts18
-rw-r--r--packages/backend/src/server/api/endpoints/channels/mute/create.ts90
-rw-r--r--packages/backend/src/server/api/endpoints/channels/mute/delete.ts73
-rw-r--r--packages/backend/src/server/api/endpoints/channels/mute/list.ts49
-rw-r--r--packages/backend/src/server/api/endpoints/channels/timeline.ts13
-rw-r--r--packages/backend/src/server/api/endpoints/notes/hybrid-timeline.ts32
-rw-r--r--packages/backend/src/server/api/endpoints/notes/local-timeline.ts16
-rw-r--r--packages/backend/src/server/api/endpoints/notes/timeline.ts52
-rw-r--r--packages/backend/src/server/api/endpoints/notes/user-list-timeline.ts13
-rw-r--r--packages/backend/src/server/api/endpoints/roles/notes.ts18
-rw-r--r--packages/backend/src/server/api/endpoints/users/notes.ts30
-rw-r--r--packages/backend/src/server/api/stream/Connection.ts18
-rw-r--r--packages/backend/src/server/api/stream/channel.ts10
-rw-r--r--packages/backend/src/server/api/stream/channels/channel.ts32
-rw-r--r--packages/backend/src/server/api/stream/channels/home-timeline.ts5
-rw-r--r--packages/backend/src/server/api/stream/channels/hybrid-timeline.ts29
-rw-r--r--packages/backend/test/e2e/antennas.ts21
-rw-r--r--packages/backend/test/e2e/timelines.ts1489
-rw-r--r--packages/backend/test/jest.setup.unit.cjs10
-rw-r--r--packages/backend/test/unit/ChannelFollowingService.ts235
-rw-r--r--packages/backend/test/unit/ChannelMutingService.ts336
-rw-r--r--packages/backend/test/unit/NoteCreateService.ts1
-rw-r--r--packages/backend/test/unit/misc/is-renote.ts1
-rw-r--r--packages/frontend/src/pages/channel.vue82
-rw-r--r--packages/misskey-js/etc/misskey-js.api.md12
-rw-r--r--packages/misskey-js/generator/package.json3
-rw-r--r--packages/misskey-js/src/autogen/apiClientJSDoc.ts33
-rw-r--r--packages/misskey-js/src/autogen/endpoint.ts6
-rw-r--r--packages/misskey-js/src/autogen/entities.ts3
-rw-r--r--packages/misskey-js/src/autogen/types.ts214
-rw-r--r--pnpm-lock.yaml163
53 files changed, 3561 insertions, 148 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 057ffd5566..d32ff1ec42 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,8 @@
## 2025.11.0
### General
+- Feat: チャンネルミュート機能の実装 #10649
+ - チャンネルの概要画面の右上からミュートできます(リンクコピー、共有、設定と同列)
- Enhance: Node.js 24.10.0をサポートするようになりました
- Enhance: DockerのNode.jsが24.10.0に更新されました
diff --git a/packages/backend/jest.config.unit.cjs b/packages/backend/jest.config.unit.cjs
index aa5992936b..957d0635c1 100644
--- a/packages/backend/jest.config.unit.cjs
+++ b/packages/backend/jest.config.unit.cjs
@@ -7,6 +7,7 @@ const base = require('./jest.config.cjs')
module.exports = {
...base,
+ globalSetup: "<rootDir>/test/jest.setup.unit.cjs",
testMatch: [
"<rootDir>/test/unit/**/*.ts",
"<rootDir>/src/**/*.test.ts",
diff --git a/packages/backend/migration/1761569941833-add-channel-muting.js b/packages/backend/migration/1761569941833-add-channel-muting.js
new file mode 100644
index 0000000000..e985df90ba
--- /dev/null
+++ b/packages/backend/migration/1761569941833-add-channel-muting.js
@@ -0,0 +1,38 @@
+/*
+ * SPDX-FileCopyrightText: syuilo and misskey-project
+ * SPDX-License-Identifier: AGPL-3.0-only
+ */
+
+export class AddChannelMuting1761569941833 {
+ name = 'AddChannelMuting1761569941833'
+
+ /**
+ * @param {QueryRunner} queryRunner
+ */
+ async up(queryRunner) {
+ await queryRunner.query(`CREATE TABLE "channel_muting" ("id" character varying(32) NOT NULL, "userId" character varying(32) NOT NULL, "channelId" character varying(32) NOT NULL, "expiresAt" TIMESTAMP WITH TIME ZONE, CONSTRAINT "PK_aec842e98f332ebd8e12f85bad6" PRIMARY KEY ("id"))`);
+ await queryRunner.query(`CREATE INDEX "IDX_34415e3062ae7a94617496e81c" ON "channel_muting" ("userId") `);
+ await queryRunner.query(`CREATE INDEX "IDX_4d534d7177fc59879d942e96d0" ON "channel_muting" ("channelId") `);
+ await queryRunner.query(`CREATE INDEX "IDX_6dd314e96806b7df65ddadff72" ON "channel_muting" ("expiresAt") `);
+ await queryRunner.query(`CREATE INDEX "IDX_b96870ed326ccc7fa243970965" ON "channel_muting" ("userId", "channelId") `);
+ await queryRunner.query(`ALTER TABLE "note" ADD "renoteChannelId" character varying(32)`);
+ await queryRunner.query(`COMMENT ON COLUMN "note"."renoteChannelId" IS '[Denormalized]'`);
+ await queryRunner.query(`ALTER TABLE "channel_muting" ADD CONSTRAINT "FK_34415e3062ae7a94617496e81c5" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
+ await queryRunner.query(`ALTER TABLE "channel_muting" ADD CONSTRAINT "FK_4d534d7177fc59879d942e96d03" FOREIGN KEY ("channelId") REFERENCES "channel"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
+ }
+
+ /**
+ * @param {QueryRunner} queryRunner
+ */
+ async down(queryRunner) {
+ await queryRunner.query(`ALTER TABLE "channel_muting" DROP CONSTRAINT "FK_4d534d7177fc59879d942e96d03"`);
+ await queryRunner.query(`ALTER TABLE "channel_muting" DROP CONSTRAINT "FK_34415e3062ae7a94617496e81c5"`);
+ await queryRunner.query(`COMMENT ON COLUMN "note"."renoteChannelId" IS '[Denormalized]'`);
+ await queryRunner.query(`ALTER TABLE "note" DROP COLUMN "renoteChannelId"`);
+ await queryRunner.query(`DROP INDEX "public"."IDX_b96870ed326ccc7fa243970965"`);
+ await queryRunner.query(`DROP INDEX "public"."IDX_6dd314e96806b7df65ddadff72"`);
+ await queryRunner.query(`DROP INDEX "public"."IDX_4d534d7177fc59879d942e96d0"`);
+ await queryRunner.query(`DROP INDEX "public"."IDX_34415e3062ae7a94617496e81c"`);
+ await queryRunner.query(`DROP TABLE "channel_muting"`);
+ }
+}
diff --git a/packages/backend/src/core/ChannelFollowingService.ts b/packages/backend/src/core/ChannelFollowingService.ts
index 12251595e2..d320a5ea36 100644
--- a/packages/backend/src/core/ChannelFollowingService.ts
+++ b/packages/backend/src/core/ChannelFollowingService.ts
@@ -6,7 +6,7 @@
import { Inject, Injectable, OnModuleInit } from '@nestjs/common';
import Redis from 'ioredis';
import { DI } from '@/di-symbols.js';
-import type { ChannelFollowingsRepository } from '@/models/_.js';
+import type { ChannelFollowingsRepository, ChannelsRepository, MiUser } from '@/models/_.js';
import { MiChannel } from '@/models/_.js';
import { IdService } from '@/core/IdService.js';
import { GlobalEvents, GlobalEventService } from '@/core/GlobalEventService.js';
@@ -23,6 +23,8 @@ export class ChannelFollowingService implements OnModuleInit {
private redisClient: Redis.Redis,
@Inject(DI.redisForSub)
private redisForSub: Redis.Redis,
+ @Inject(DI.channelsRepository)
+ private channelsRepository: ChannelsRepository,
@Inject(DI.channelFollowingsRepository)
private channelFollowingsRepository: ChannelFollowingsRepository,
private idService: IdService,
@@ -45,6 +47,50 @@ export class ChannelFollowingService implements OnModuleInit {
onModuleInit() {
}
+ /**
+ * フォローしているチャンネルの一覧を取得する.
+ * @param params
+ * @param [opts]
+ * @param {(boolean|undefined)} [opts.idOnly=false] チャンネルIDのみを取得するかどうか. ID以外のフィールドに値がセットされなくなり、他テーブルとのJOINも一切されなくなるので注意.
+ * @param {(boolean|undefined)} [opts.joinUser=undefined] チャンネルオーナーのユーザ情報をJOINするかどうか(falseまたは省略時はJOINしない).
+ * @param {(boolean|undefined)} [opts.joinBannerFile=undefined] バナー画像のドライブファイルをJOINするかどうか(falseまたは省略時はJOINしない).
+ */
+ @bindThis
+ public async list(
+ params: {
+ requestUserId: MiUser['id'],
+ },
+ opts?: {
+ idOnly?: boolean;
+ joinUser?: boolean;
+ joinBannerFile?: boolean;
+ },
+ ): Promise<MiChannel[]> {
+ if (opts?.idOnly) {
+ const q = this.channelFollowingsRepository.createQueryBuilder('channel_following')
+ .select('channel_following.followeeId')
+ .where('channel_following.followerId = :userId', { userId: params.requestUserId });
+
+ return q
+ .getRawMany<{ channel_following_followeeId: string }>()
+ .then(xs => xs.map(x => ({ id: x.channel_following_followeeId } as MiChannel)));
+ } else {
+ const q = this.channelsRepository.createQueryBuilder('channel')
+ .innerJoin('channel_following', 'channel_following', 'channel_following.followeeId = channel.id')
+ .where('channel_following.followerId = :userId', { userId: params.requestUserId });
+
+ if (opts?.joinUser) {
+ q.innerJoinAndSelect('channel.user', 'user');
+ }
+
+ if (opts?.joinBannerFile) {
+ q.leftJoinAndSelect('channel.banner', 'drive_file');
+ }
+
+ return q.getMany();
+ }
+ }
+
@bindThis
public async follow(
requestUser: MiLocalUser,
diff --git a/packages/backend/src/core/ChannelMutingService.ts b/packages/backend/src/core/ChannelMutingService.ts
new file mode 100644
index 0000000000..bf5b848d44
--- /dev/null
+++ b/packages/backend/src/core/ChannelMutingService.ts
@@ -0,0 +1,224 @@
+/*
+ * SPDX-FileCopyrightText: syuilo and misskey-project
+ * SPDX-License-Identifier: AGPL-3.0-only
+ */
+
+import { Inject, Injectable } from '@nestjs/common';
+import Redis from 'ioredis';
+import { Brackets, In } from 'typeorm';
+import { DI } from '@/di-symbols.js';
+import type { ChannelMutingRepository, ChannelsRepository, MiChannel, MiChannelMuting, MiUser } from '@/models/_.js';
+import { IdService } from '@/core/IdService.js';
+import { GlobalEvents, GlobalEventService } from '@/core/GlobalEventService.js';
+import { bindThis } from '@/decorators.js';
+import { RedisKVCache } from '@/misc/cache.js';
+
+@Injectable()
+export class ChannelMutingService {
+ public mutingChannelsCache: RedisKVCache<Set<string>>;
+
+ constructor(
+ @Inject(DI.redis)
+ private redisClient: Redis.Redis,
+ @Inject(DI.redisForSub)
+ private redisForSub: Redis.Redis,
+ @Inject(DI.channelsRepository)
+ private channelsRepository: ChannelsRepository,
+ @Inject(DI.channelMutingRepository)
+ private channelMutingRepository: ChannelMutingRepository,
+ private idService: IdService,
+ private globalEventService: GlobalEventService,
+ ) {
+ this.mutingChannelsCache = new RedisKVCache<Set<string>>(this.redisClient, 'channelMutingChannels', {
+ lifetime: 1000 * 60 * 30, // 30m
+ memoryCacheLifetime: 1000 * 60, // 1m
+ fetcher: (userId) => this.channelMutingRepository.find({
+ where: { userId: userId },
+ select: ['channelId'],
+ }).then(xs => new Set(xs.map(x => x.channelId))),
+ toRedisConverter: (value) => JSON.stringify(Array.from(value)),
+ fromRedisConverter: (value) => new Set(JSON.parse(value)),
+ });
+
+ this.redisForSub.on('message', this.onMessage);
+ }
+
+ /**
+ * ミュートしているチャンネルの一覧を取得する.
+ * @param params
+ * @param [opts]
+ * @param {(boolean|undefined)} [opts.idOnly=false] チャンネルIDのみを取得するかどうか. ID以外のフィールドに値がセットされなくなり、他テーブルとのJOINも一切されなくなるので注意.
+ * @param {(boolean|undefined)} [opts.joinUser=undefined] チャンネルオーナーのユーザ情報をJOINするかどうか(falseまたは省略時はJOINしない).
+ * @param {(boolean|undefined)} [opts.joinBannerFile=undefined] バナー画像のドライブファイルをJOINするかどうか(falseまたは省略時はJOINしない).
+ */
+ @bindThis
+ public async list(
+ params: {
+ requestUserId: MiUser['id'],
+ },
+ opts?: {
+ idOnly?: boolean;
+ joinUser?: boolean;
+ joinBannerFile?: boolean;
+ },
+ ): Promise<MiChannel[]> {
+ if (opts?.idOnly) {
+ const q = this.channelMutingRepository.createQueryBuilder('channel_muting')
+ .select('channel_muting.channelId')
+ .where('channel_muting.userId = :userId', { userId: params.requestUserId })
+ .andWhere(new Brackets(qb => {
+ qb.where('channel_muting.expiresAt IS NULL')
+ .orWhere('channel_muting.expiresAt > :now', { now: new Date() });
+ }));
+
+ return q
+ .getRawMany<{ channel_muting_channelId: string }>()
+ .then(xs => xs.map(x => ({ id: x.channel_muting_channelId } as MiChannel)));
+ } else {
+ const q = this.channelsRepository.createQueryBuilder('channel')
+ .innerJoin('channel_muting', 'channel_muting', 'channel_muting.channelId = channel.id')
+ .where('channel_muting.userId = :userId', { userId: params.requestUserId })
+ .andWhere(new Brackets(qb => {
+ qb.where('channel_muting.expiresAt IS NULL')
+ .orWhere('channel_muting.expiresAt > :now', { now: new Date() });
+ }));
+
+ if (opts?.joinUser) {
+ q.innerJoinAndSelect('channel.user', 'user');
+ }
+
+ if (opts?.joinBannerFile) {
+ q.leftJoinAndSelect('channel.banner', 'drive_file');
+ }
+
+ return q.getMany();
+ }
+ }
+
+ /**
+ * 期限切れのチャンネルミュート情報を取得する.
+ *
+ * @param [opts]
+ * @param {(boolean|undefined)} [opts.joinUser=undefined] チャンネルミュートを設定したユーザ情報をJOINするかどうか(falseまたは省略時はJOINしない).
+ * @param {(boolean|undefined)} [opts.joinChannel=undefined] ミュート先のチャンネル情報をJOINするかどうか(falseまたは省略時はJOINしない).
+ */
+ public async findExpiredMutings(opts?: {
+ joinUser?: boolean;
+ joinChannel?: boolean;
+ }): Promise<MiChannelMuting[]> {
+ const now = new Date();
+ const q = this.channelMutingRepository.createQueryBuilder('channel_muting')
+ .where('channel_muting.expiresAt < :now', { now });
+
+ if (opts?.joinUser) {
+ q.innerJoinAndSelect('channel_muting.user', 'user');
+ }
+
+ if (opts?.joinChannel) {
+ q.leftJoinAndSelect('channel_muting.channel', 'channel');
+ }
+
+ return q.getMany();
+ }
+
+ /**
+ * 既にミュートされているかどうかをキャッシュから取得する.
+ * @param params
+ * @param params.requestUserId
+ */
+ @bindThis
+ public async isMuted(params: {
+ requestUserId: MiUser['id'],
+ targetChannelId: MiChannel['id'],
+ }): Promise<boolean> {
+ const mutedChannels = await this.mutingChannelsCache.get(params.requestUserId);
+ return (mutedChannels?.has(params.targetChannelId) ?? false);
+ }
+
+ /**
+ * チャンネルをミュートする.
+ * @param params
+ * @param {(Date|null|undefined)} [params.expiresAt] ミュートの有効期限. nullまたは省略時は無期限.
+ */
+ @bindThis
+ public async mute(params: {
+ requestUserId: MiUser['id'],
+ targetChannelId: MiChannel['id'],
+ expiresAt?: Date | null,
+ }): Promise<void> {
+ await this.channelMutingRepository.insert({
+ id: this.idService.gen(),
+ userId: params.requestUserId,
+ channelId: params.targetChannelId,
+ expiresAt: params.expiresAt,
+ });
+
+ this.globalEventService.publishInternalEvent('muteChannel', {
+ userId: params.requestUserId,
+ channelId: params.targetChannelId,
+ });
+ }
+
+ /**
+ * チャンネルのミュートを解除する.
+ * @param params
+ */
+ @bindThis
+ public async unmute(params: {
+ requestUserId: MiUser['id'],
+ targetChannelId: MiChannel['id'],
+ }): Promise<void> {
+ await this.channelMutingRepository.delete({
+ userId: params.requestUserId,
+ channelId: params.targetChannelId,
+ });
+
+ this.globalEventService.publishInternalEvent('unmuteChannel', {
+ userId: params.requestUserId,
+ channelId: params.targetChannelId,
+ });
+ }
+
+ /**
+ * 期限切れのチャンネルミュート情報を削除する.
+ */
+ @bindThis
+ public async eraseExpiredMutings(): Promise<void> {
+ const expiredMutings = await this.findExpiredMutings();
+ await this.channelMutingRepository.delete({ id: In(expiredMutings.map(x => x.id)) });
+
+ const userIds = [...new Set(expiredMutings.map(x => x.userId))];
+ for (const userId of userIds) {
+ this.mutingChannelsCache.refresh(userId).then();
+ }
+ }
+
+ @bindThis
+ private async onMessage(_: string, data: string): Promise<void> {
+ const obj = JSON.parse(data);
+
+ if (obj.channel === 'internal') {
+ const { type, body } = obj.message as GlobalEvents['internal']['payload'];
+ switch (type) {
+ case 'muteChannel': {
+ this.mutingChannelsCache.refresh(body.userId).then();
+ break;
+ }
+ case 'unmuteChannel': {
+ this.mutingChannelsCache.delete(body.userId).then();
+ break;
+ }
+ }
+ }
+ }
+
+ @bindThis
+ public dispose(): void {
+ this.mutingChannelsCache.dispose();
+ }
+
+ @bindThis
+ public onApplicationShutdown(signal?: string | undefined): void {
+ this.dispose();
+ }
+}
diff --git a/packages/backend/src/core/CoreModule.ts b/packages/backend/src/core/CoreModule.ts
index a30bff0fe4..8c8d22c77d 100644
--- a/packages/backend/src/core/CoreModule.ts
+++ b/packages/backend/src/core/CoreModule.ts
@@ -15,6 +15,7 @@ import { SystemWebhookService } from '@/core/SystemWebhookService.js';
import { UserSearchService } from '@/core/UserSearchService.js';
import { WebhookTestService } from '@/core/WebhookTestService.js';
import { FlashService } from '@/core/FlashService.js';
+import { ChannelMutingService } from '@/core/ChannelMutingService.js';
import { AccountMoveService } from './AccountMoveService.js';
import { AccountUpdateService } from './AccountUpdateService.js';
import { AiService } from './AiService.js';
@@ -225,6 +226,7 @@ const $FeaturedService: Provider = { provide: 'FeaturedService', useExisting: Fe
const $FanoutTimelineService: Provider = { provide: 'FanoutTimelineService', useExisting: FanoutTimelineService };
const $FanoutTimelineEndpointService: Provider = { provide: 'FanoutTimelineEndpointService', useExisting: FanoutTimelineEndpointService };
const $ChannelFollowingService: Provider = { provide: 'ChannelFollowingService', useExisting: ChannelFollowingService };
+const $ChannelMutingService: Provider = { provide: 'ChannelMutingService', useExisting: ChannelMutingService };
const $ChatService: Provider = { provide: 'ChatService', useExisting: ChatService };
const $RegistryApiService: Provider = { provide: 'RegistryApiService', useExisting: RegistryApiService };
const $ReversiService: Provider = { provide: 'ReversiService', useExisting: ReversiService };
@@ -378,6 +380,7 @@ const $ApQuestionService: Provider = { provide: 'ApQuestionService', useExisting
FanoutTimelineService,
FanoutTimelineEndpointService,
ChannelFollowingService,
+ ChannelMutingService,
ChatService,
RegistryApiService,
ReversiService,
@@ -527,6 +530,7 @@ const $ApQuestionService: Provider = { provide: 'ApQuestionService', useExisting
$FanoutTimelineService,
$FanoutTimelineEndpointService,
$ChannelFollowingService,
+ $ChannelMutingService,
$ChatService,
$RegistryApiService,
$ReversiService,
@@ -677,6 +681,7 @@ const $ApQuestionService: Provider = { provide: 'ApQuestionService', useExisting
FanoutTimelineService,
FanoutTimelineEndpointService,
ChannelFollowingService,
+ ChannelMutingService,
ChatService,
RegistryApiService,
ReversiService,
@@ -824,6 +829,7 @@ const $ApQuestionService: Provider = { provide: 'ApQuestionService', useExisting
$FanoutTimelineService,
$FanoutTimelineEndpointService,
$ChannelFollowingService,
+ $ChannelMutingService,
$ChatService,
$RegistryApiService,
$ReversiService,
diff --git a/packages/backend/src/core/FanoutTimelineEndpointService.ts b/packages/backend/src/core/FanoutTimelineEndpointService.ts
index 94c5691bf4..e39d70d683 100644
--- a/packages/backend/src/core/FanoutTimelineEndpointService.ts
+++ b/packages/backend/src/core/FanoutTimelineEndpointService.ts
@@ -19,6 +19,8 @@ import { isQuote, isRenote } from '@/misc/is-renote.js';
import { CacheService } from '@/core/CacheService.js';
import { isReply } from '@/misc/is-reply.js';
import { isInstanceMuted } from '@/misc/is-instance-muted.js';
+import { ChannelMutingService } from '@/core/ChannelMutingService.js';
+import { isChannelRelated } from '@/misc/is-channel-related.js';
type NoteFilter = (note: MiNote) => boolean;
@@ -35,6 +37,7 @@ type TimelineOptions = {
ignoreAuthorFromBlock?: boolean;
ignoreAuthorFromMute?: boolean;
ignoreAuthorFromInstanceBlock?: boolean;
+ ignoreAuthorChannelFromMute?: boolean;
excludeNoFiles?: boolean;
excludeReplies?: boolean;
excludePureRenotes: boolean;
@@ -55,6 +58,7 @@ export class FanoutTimelineEndpointService {
private cacheService: CacheService,
private fanoutTimelineService: FanoutTimelineService,
private utilityService: UtilityService,
+ private channelMutingService: ChannelMutingService,
) {
}
@@ -111,11 +115,13 @@ export class FanoutTimelineEndpointService {
userIdsWhoMeMutingRenotes,
userIdsWhoBlockingMe,
userMutedInstances,
+ userMutedChannels,
] = await Promise.all([
this.cacheService.userMutingsCache.fetch(ps.me.id),
this.cacheService.renoteMutingsCache.fetch(ps.me.id),
this.cacheService.userBlockedCache.fetch(ps.me.id),
this.cacheService.userProfileCache.fetch(me.id).then(p => new Set(p.mutedInstances)),
+ this.channelMutingService.mutingChannelsCache.fetch(me.id),
]);
const parentFilter = filter;
@@ -126,6 +132,7 @@ export class FanoutTimelineEndpointService {
if (isUserRelated(note.renote, userIdsWhoMeMuting, ps.ignoreAuthorFromMute)) return false;
if (!ps.ignoreAuthorFromMute && isRenote(note) && !isQuote(note) && userIdsWhoMeMutingRenotes.has(note.userId)) return false;
if (isInstanceMuted(note, userMutedInstances)) return false;
+ if (isChannelRelated(note, userMutedChannels, ps.ignoreAuthorChannelFromMute)) return false;
return parentFilter(note);
};
diff --git a/packages/backend/src/core/GlobalEventService.ts b/packages/backend/src/core/GlobalEventService.ts
index 3215b41c8d..f4c747b139 100644
--- a/packages/backend/src/core/GlobalEventService.ts
+++ b/packages/backend/src/core/GlobalEventService.ts
@@ -255,6 +255,8 @@ export interface InternalEventTypes {
metaUpdated: { before?: MiMeta; after: MiMeta; };
followChannel: { userId: MiUser['id']; channelId: MiChannel['id']; };
unfollowChannel: { userId: MiUser['id']; channelId: MiChannel['id']; };
+ muteChannel: { userId: MiUser['id']; channelId: MiChannel['id']; };
+ unmuteChannel: { userId: MiUser['id']; channelId: MiChannel['id']; };
updateUserProfile: MiUserProfile;
mute: { muterId: MiUser['id']; muteeId: MiUser['id']; };
unmute: { muterId: MiUser['id']; muteeId: MiUser['id']; };
diff --git a/packages/backend/src/core/NoteCreateService.ts b/packages/backend/src/core/NoteCreateService.ts
index b6acf4c5fb..748f2cbad9 100644
--- a/packages/backend/src/core/NoteCreateService.ts
+++ b/packages/backend/src/core/NoteCreateService.ts
@@ -604,6 +604,7 @@ export class NoteCreateService implements OnApplicationShutdown {
replyUserHost: data.reply ? data.reply.userHost : null,
renoteUserId: data.renote ? data.renote.userId : null,
renoteUserHost: data.renote ? data.renote.userHost : null,
+ renoteChannelId: data.renote ? data.renote.channelId : null,
userHost: user.host,
});
diff --git a/packages/backend/src/core/WebhookTestService.ts b/packages/backend/src/core/WebhookTestService.ts
index 6714bda9a9..b112912b1b 100644
--- a/packages/backend/src/core/WebhookTestService.ts
+++ b/packages/backend/src/core/WebhookTestService.ts
@@ -106,6 +106,7 @@ function generateDummyNote(override?: Partial<MiNote>): MiNote {
replyUserHost: null,
renoteUserId: null,
renoteUserHost: null,
+ renoteChannelId: null,
...override,
};
}
diff --git a/packages/backend/src/core/entities/ChannelEntityService.ts b/packages/backend/src/core/entities/ChannelEntityService.ts
index 1ba7ca8e57..9ee918bea3 100644
--- a/packages/backend/src/core/entities/ChannelEntityService.ts
+++ b/packages/backend/src/core/entities/ChannelEntityService.ts
@@ -4,36 +4,40 @@
*/
import { Inject, Injectable } from '@nestjs/common';
+import { In } from 'typeorm';
import { DI } from '@/di-symbols.js';
-import type { ChannelFavoritesRepository, ChannelFollowingsRepository, ChannelsRepository, DriveFilesRepository, NotesRepository } from '@/models/_.js';
+import type {
+ ChannelFavoritesRepository,
+ ChannelFollowingsRepository, ChannelMutingRepository,
+ ChannelsRepository,
+ DriveFilesRepository,
+ MiDriveFile,
+ MiNote,
+ NotesRepository,
+} from '@/models/_.js';
import type { Packed } from '@/misc/json-schema.js';
-import type { } from '@/models/Blocking.js';
import type { MiUser } from '@/models/User.js';
import type { MiChannel } from '@/models/Channel.js';
import { bindThis } from '@/decorators.js';
import { IdService } from '@/core/IdService.js';
import { DriveFileEntityService } from './DriveFileEntityService.js';
import { NoteEntityService } from './NoteEntityService.js';
-import { In } from 'typeorm';
@Injectable()
export class ChannelEntityService {
constructor(
@Inject(DI.channelsRepository)
private channelsRepository: ChannelsRepository,
-
@Inject(DI.channelFollowingsRepository)
private channelFollowingsRepository: ChannelFollowingsRepository,
-
@Inject(DI.channelFavoritesRepository)
private channelFavoritesRepository: ChannelFavoritesRepository,
-
+ @Inject(DI.channelMutingRepository)
+ private channelMutingRepository: ChannelMutingRepository,
@Inject(DI.notesRepository)
private notesRepository: NotesRepository,
-
@Inject(DI.driveFilesRepository)
private driveFilesRepository: DriveFilesRepository,
-
private noteEntityService: NoteEntityService,
private driveFileEntityService: DriveFileEntityService,
private idService: IdService,
@@ -45,31 +49,59 @@ export class ChannelEntityService {
src: MiChannel['id'] | MiChannel,
me?: { id: MiUser['id'] } | null | undefined,
detailed?: boolean,
+ opts?: {
+ bannerFiles?: Map<MiDriveFile['id'], MiDriveFile>;
+ followings?: Set<MiChannel['id']>;
+ favorites?: Set<MiChannel['id']>;
+ muting?: Set<MiChannel['id']>;
+ pinnedNotes?: Map<MiNote['id'], MiNote>;
+ },
): Promise<Packed<'Channel'>> {
const channel = typeof src === 'object' ? src : await this.channelsRepository.findOneByOrFail({ id: src });
- const meId = me ? me.id : null;
- const banner = channel.bannerId ? await this.driveFilesRepository.findOneBy({ id: channel.bannerId }) : null;
+ let bannerFile: MiDriveFile | null = null;
+ if (channel.bannerId) {
+ bannerFile = opts?.bannerFiles?.get(channel.bannerId)
+ ?? await this.driveFilesRepository.findOneByOrFail({ id: channel.bannerId });
+ }
+
+ let isFollowing = false;
+ let isFavorited = false;
+ let isMuting = false;
+ if (me) {
+ isFollowing = opts?.followings?.has(channel.id) ?? await this.channelFollowingsRepository.exists({
+ where: {
+ followerId: me.id,
+ followeeId: channel.id,
+ },
+ });
- const isFollowing = meId ? await this.channelFollowingsRepository.exists({
- where: {
- followerId: meId,
- followeeId: channel.id,
- },
- }) : false;
+ isFavorited = opts?.favorites?.has(channel.id) ?? await this.channelFavoritesRepository.exists({
+ where: {
+ userId: me.id,
+ channelId: channel.id,
+ },
+ });
- const isFavorited = meId ? await this.channelFavoritesRepository.exists({
- where: {
- userId: meId,
- channelId: channel.id,
- },
- }) : false;
+ isMuting = opts?.muting?.has(channel.id) ?? await this.channelMutingRepository.exists({
+ where: {
+ userId: me.id,
+ channelId: channel.id,
+ },
+ });
+ }
- const pinnedNotes = channel.pinnedNoteIds.length > 0 ? await this.notesRepository.find({
- where: {
- id: In(channel.pinnedNoteIds),
- },
- }) : [];
+ const pinnedNotes = Array.of<MiNote>();
+ if (channel.pinnedNoteIds.length > 0) {
+ pinnedNotes.push(
+ ...(
+ opts?.pinnedNotes
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
+ ? channel.pinnedNoteIds.map(it => opts.pinnedNotes!.get(it)).filter(it => it != null)
+ : await this.notesRepository.findBy({ id: In(channel.pinnedNoteIds) })
+ ),
+ );
+ }
return {
id: channel.id,
@@ -78,7 +110,7 @@ export class ChannelEntityService {
name: channel.name,
description: channel.description,
userId: channel.userId,
- bannerUrl: banner ? this.driveFileEntityService.getPublicUrl(banner) : null,
+ bannerUrl: bannerFile ? this.driveFileEntityService.getPublicUrl(bannerFile) : null,
pinnedNoteIds: channel.pinnedNoteIds,
color: channel.color,
isArchived: channel.isArchived,
@@ -90,6 +122,7 @@ export class ChannelEntityService {
...(me ? {
isFollowing,
isFavorited,
+ isMuting,
hasUnreadNote: false, // 後方互換性のため
} : {}),
@@ -98,5 +131,72 @@ export class ChannelEntityService {
} : {}),
};
}
+
+ @bindThis
+ public async packMany(
+ src: MiChannel['id'][] | MiChannel[],
+ me?: { id: MiUser['id'] } | null | undefined,
+ detailed?: boolean,
+ ): Promise<Packed<'Channel'>[]> {
+ // IDのみの要素がある場合、DBからオブジェクトを取得して補う
+ const channels = src.filter(it => typeof it === 'object') as MiChannel[];
+ channels.push(
+ ...(await this.channelsRepository.find({
+ where: {
+ id: In(src.filter(it => typeof it !== 'object') as MiChannel['id'][]),
+ },
+ })),
+ );
+ channels.sort((a, b) => a.id.localeCompare(b.id));
+
+ const bannerFiles = await this.driveFilesRepository
+ .findBy({
+ id: In(channels.map(it => it.bannerId).filter(it => it != null)),
+ })
+ .then(it => new Map(it.map(it => [it.id, it])));
+
+ const followings = me
+ ? await this.channelFollowingsRepository
+ .findBy({
+ followerId: me.id,
+ followeeId: In(channels.map(it => it.id)),
+ })
+ .then(it => new Set(it.map(it => it.followeeId)))
+ : new Set<MiChannel['id']>();
+
+ const favorites = me
+ ? await this.channelFavoritesRepository
+ .findBy({
+ userId: me.id,
+ channelId: In(channels.map(it => it.id)),
+ })
+ .then(it => new Set(it.map(it => it.channelId)))
+ : new Set<MiChannel['id']>();
+
+ 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<MiChannel['id']>();
+
+ const pinnedNotes = await this.notesRepository
+ .find({
+ where: {
+ id: In(channels.flatMap(it => it.pinnedNoteIds)),
+ },
+ })
+ .then(it => new Map(it.map(it => [it.id, it])));
+
+ return Promise.all(channels.map(it => this.pack(it, me, detailed, {
+ bannerFiles,
+ followings,
+ favorites,
+ muting,
+ pinnedNotes,
+ })));
+ }
}
diff --git a/packages/backend/src/di-symbols.ts b/packages/backend/src/di-symbols.ts
index c915133453..b9ca76233c 100644
--- a/packages/backend/src/di-symbols.ts
+++ b/packages/backend/src/di-symbols.ts
@@ -70,6 +70,7 @@ export const DI = {
channelsRepository: Symbol('channelsRepository'),
channelFollowingsRepository: Symbol('channelFollowingsRepository'),
channelFavoritesRepository: Symbol('channelFavoritesRepository'),
+ channelMutingRepository: Symbol('channelMutingRepository'),
registryItemsRepository: Symbol('registryItemsRepository'),
webhooksRepository: Symbol('webhooksRepository'),
systemWebhooksRepository: Symbol('systemWebhooksRepository'),
diff --git a/packages/backend/src/misc/is-channel-related.ts b/packages/backend/src/misc/is-channel-related.ts
new file mode 100644
index 0000000000..fef736dad6
--- /dev/null
+++ b/packages/backend/src/misc/is-channel-related.ts
@@ -0,0 +1,31 @@
+/*
+ * SPDX-FileCopyrightText: syuilo and misskey-project
+ * SPDX-License-Identifier: AGPL-3.0-only
+ */
+
+import { MiNote } from '@/models/Note.js';
+import { Packed } from '@/misc/json-schema.js';
+
+/**
+ * {@link note}が{@link channelIds}のチャンネルに関連するかどうかを判定し、関連する場合はtrueを返します。
+ * 関連するというのは、{@link channelIds}のチャンネルに向けての投稿であるか、またはそのチャンネルの投稿をリノート・引用リノートした投稿であるかを指します。
+ *
+ * @param note 確認対象のノート
+ * @param channelIds 確認対象のチャンネルID一覧
+ * @param ignoreAuthor trueの場合、ノートの所属チャンネルが{@link channelIds}に含まれていても無視します(デフォルトはfalse)
+ */
+export function isChannelRelated(note: MiNote | Packed<'Note'>, channelIds: Set<string>, ignoreAuthor = false): boolean {
+ // ノートの所属チャンネルが確認対象のチャンネルID一覧に含まれている場合
+ if (!ignoreAuthor && note.channelId && channelIds.has(note.channelId)) {
+ return true;
+ }
+
+ const renoteChannelId = note.renote?.channelId;
+ if (renoteChannelId != null && renoteChannelId !== note.channelId && channelIds.has(renoteChannelId)) {
+ return true;
+ }
+
+ // NOTE: リプライはchannelIdのチェックだけでOKなはずなので見てない(チャンネルのノートにチャンネル外からのリプライまたはその逆はないはずなので)
+
+ return false;
+}
diff --git a/packages/backend/src/models/ChannelMuting.ts b/packages/backend/src/models/ChannelMuting.ts
new file mode 100644
index 0000000000..11ac7e5cef
--- /dev/null
+++ b/packages/backend/src/models/ChannelMuting.ts
@@ -0,0 +1,46 @@
+/*
+ * SPDX-FileCopyrightText: syuilo and misskey-project
+ * SPDX-License-Identifier: AGPL-3.0-only
+ */
+
+import { Column, Entity, Index, JoinColumn, ManyToOne, PrimaryColumn } from 'typeorm';
+import { id } from './util/id.js';
+import { MiUser } from './User.js';
+import { MiChannel } from './Channel.js';
+
+@Entity('channel_muting')
+@Index(['userId', 'channelId'], {})
+export class MiChannelMuting {
+ @PrimaryColumn(id())
+ public id: string;
+
+ @Index()
+ @Column({
+ ...id(),
+ })
+ public userId: MiUser['id'];
+
+ @ManyToOne(type => MiUser, {
+ onDelete: 'CASCADE',
+ })
+ @JoinColumn()
+ public user: MiUser | null;
+
+ @Index()
+ @Column({
+ ...id(),
+ })
+ public channelId: MiChannel['id'];
+
+ @ManyToOne(type => MiChannel, {
+ onDelete: 'CASCADE',
+ })
+ @JoinColumn()
+ public channel: MiChannel | null;
+
+ @Index()
+ @Column('timestamp with time zone', {
+ nullable: true,
+ })
+ public expiresAt: Date | null;
+}
diff --git a/packages/backend/src/models/Note.ts b/packages/backend/src/models/Note.ts
index 26d5c1d535..23e5960b60 100644
--- a/packages/backend/src/models/Note.ts
+++ b/packages/backend/src/models/Note.ts
@@ -248,6 +248,14 @@ export class MiNote {
})
public renoteUserHost: string | null;
+ @Column({
+ ...id(),
+ nullable: true,
+ comment: '[Denormalized]',
+ })
+ public renoteChannelId: MiChannel['id'] | null;
+ //#endregion
+
constructor(data: Partial<MiNote>) {
if (data == null) return;
diff --git a/packages/backend/src/models/RepositoryModule.ts b/packages/backend/src/models/RepositoryModule.ts
index 146dbbc3b8..e3db6f8838 100644
--- a/packages/backend/src/models/RepositoryModule.ts
+++ b/packages/backend/src/models/RepositoryModule.ts
@@ -21,6 +21,7 @@ import {
MiChannel,
MiChannelFavorite,
MiChannelFollowing,
+ MiChannelMuting,
MiClip,
MiClipFavorite,
MiClipNote,
@@ -429,6 +430,12 @@ const $channelFavoritesRepository: Provider = {
inject: [DI.db],
};
+const $channelMutingRepository: Provider = {
+ provide: DI.channelMutingRepository,
+ useFactory: (db: DataSource) => db.getRepository(MiChannelMuting).extend(miRepository as MiRepository<MiChannelMuting>),
+ inject: [DI.db],
+};
+
const $registryItemsRepository: Provider = {
provide: DI.registryItemsRepository,
useFactory: (db: DataSource) => db.getRepository(MiRegistryItem).extend(miRepository as MiRepository<MiRegistryItem>),
@@ -597,6 +604,7 @@ const $reversiGamesRepository: Provider = {
$channelsRepository,
$channelFollowingsRepository,
$channelFavoritesRepository,
+ $channelMutingRepository,
$registryItemsRepository,
$webhooksRepository,
$systemWebhooksRepository,
@@ -674,6 +682,7 @@ const $reversiGamesRepository: Provider = {
$channelsRepository,
$channelFollowingsRepository,
$channelFavoritesRepository,
+ $channelMutingRepository,
$registryItemsRepository,
$webhooksRepository,
$systemWebhooksRepository,
diff --git a/packages/backend/src/models/_.ts b/packages/backend/src/models/_.ts
index 84b5cbed0a..8c77a225c8 100644
--- a/packages/backend/src/models/_.ts
+++ b/packages/backend/src/models/_.ts
@@ -32,6 +32,7 @@ import { MiBubbleGameRecord } from '@/models/BubbleGameRecord.js';
import { MiChannel } from '@/models/Channel.js';
import { MiChannelFavorite } from '@/models/ChannelFavorite.js';
import { MiChannelFollowing } from '@/models/ChannelFollowing.js';
+import { MiChannelMuting } from "@/models/ChannelMuting.js";
import { MiChatApproval } from '@/models/ChatApproval.js';
import { MiChatMessage } from '@/models/ChatMessage.js';
import { MiChatRoom } from '@/models/ChatRoom.js';
@@ -172,6 +173,7 @@ export {
MiBlocking,
MiChannelFollowing,
MiChannelFavorite,
+ MiChannelMuting,
MiClip,
MiClipNote,
MiClipFavorite,
@@ -251,6 +253,7 @@ export type AuthSessionsRepository = Repository<MiAuthSession> & MiRepository<Mi
export type BlockingsRepository = Repository<MiBlocking> & MiRepository<MiBlocking>;
export type ChannelFollowingsRepository = Repository<MiChannelFollowing> & MiRepository<MiChannelFollowing>;
export type ChannelFavoritesRepository = Repository<MiChannelFavorite> & MiRepository<MiChannelFavorite>;
+export type ChannelMutingRepository = Repository<MiChannelMuting> & MiRepository<MiChannelMuting>;
export type ClipsRepository = Repository<MiClip> & MiRepository<MiClip>;
export type ClipNotesRepository = Repository<MiClipNote> & MiRepository<MiClipNote>;
export type ClipFavoritesRepository = Repository<MiClipFavorite> & MiRepository<MiClipFavorite>;
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/backend/src/postgres.ts b/packages/backend/src/postgres.ts
index f6cbbbe64c..a3e659c110 100644
--- a/packages/backend/src/postgres.ts
+++ b/packages/backend/src/postgres.ts
@@ -25,6 +25,7 @@ import { MiAuthSession } from '@/models/AuthSession.js';
import { MiBlocking } from '@/models/Blocking.js';
import { MiChannelFollowing } from '@/models/ChannelFollowing.js';
import { MiChannelFavorite } from '@/models/ChannelFavorite.js';
+import { MiChannelMuting } from "@/models/ChannelMuting.js";
import { MiClip } from '@/models/Clip.js';
import { MiClipNote } from '@/models/ClipNote.js';
import { MiClipFavorite } from '@/models/ClipFavorite.js';
@@ -239,6 +240,7 @@ export const entities = [
MiChannel,
MiChannelFollowing,
MiChannelFavorite,
+ MiChannelMuting,
MiRegistryItem,
MiAd,
MiPasswordResetRequest,
diff --git a/packages/backend/src/queue/processors/CheckExpiredMutingsProcessorService.ts b/packages/backend/src/queue/processors/CheckExpiredMutingsProcessorService.ts
index 448fc9c763..e898e6dd48 100644
--- a/packages/backend/src/queue/processors/CheckExpiredMutingsProcessorService.ts
+++ b/packages/backend/src/queue/processors/CheckExpiredMutingsProcessorService.ts
@@ -4,14 +4,13 @@
*/
import { Inject, Injectable } from '@nestjs/common';
-import { In } from 'typeorm';
import { DI } from '@/di-symbols.js';
import type { MutingsRepository } from '@/models/_.js';
import type Logger from '@/logger.js';
import { bindThis } from '@/decorators.js';
import { UserMutingService } from '@/core/UserMutingService.js';
+import { ChannelMutingService } from '@/core/ChannelMutingService.js';
import { QueueLoggerService } from '../QueueLoggerService.js';
-import type * as Bull from 'bullmq';
@Injectable()
export class CheckExpiredMutingsProcessorService {
@@ -22,6 +21,7 @@ export class CheckExpiredMutingsProcessorService {
private mutingsRepository: MutingsRepository,
private userMutingService: UserMutingService,
+ private channelMutingService: ChannelMutingService,
private queueLoggerService: QueueLoggerService,
) {
this.logger = this.queueLoggerService.logger.createSubLogger('check-expired-mutings');
@@ -41,6 +41,8 @@ export class CheckExpiredMutingsProcessorService {
await this.userMutingService.unmute(expired);
}
+ await this.channelMutingService.eraseExpiredMutings();
+
this.logger.succ('All expired mutings checked.');
}
}
diff --git a/packages/backend/src/server/api/StreamingApiServerService.ts b/packages/backend/src/server/api/StreamingApiServerService.ts
index 2a4e1fc574..21f2f0b7e2 100644
--- a/packages/backend/src/server/api/StreamingApiServerService.ts
+++ b/packages/backend/src/server/api/StreamingApiServerService.ts
@@ -15,6 +15,7 @@ import { CacheService } from '@/core/CacheService.js';
import { MiLocalUser } from '@/models/User.js';
import { UserService } from '@/core/UserService.js';
import { ChannelFollowingService } from '@/core/ChannelFollowingService.js';
+import { ChannelMutingService } from '@/core/ChannelMutingService.js';
import { AuthenticateService, AuthenticationError } from './AuthenticateService.js';
import MainStreamConnection from './stream/Connection.js';
import { ChannelsService } from './stream/ChannelsService.js';
@@ -39,6 +40,7 @@ export class StreamingApiServerService {
private notificationService: NotificationService,
private usersService: UserService,
private channelFollowingService: ChannelFollowingService,
+ private channelMutingService: ChannelMutingService,
) {
}
@@ -97,6 +99,7 @@ export class StreamingApiServerService {
this.notificationService,
this.cacheService,
this.channelFollowingService,
+ this.channelMutingService,
user, app,
);
diff --git a/packages/backend/src/server/api/endpoint-list.ts b/packages/backend/src/server/api/endpoint-list.ts
index f4aa07875d..9aecc0f0fd 100644
--- a/packages/backend/src/server/api/endpoint-list.ts
+++ b/packages/backend/src/server/api/endpoint-list.ts
@@ -143,6 +143,9 @@ export * as 'channels/timeline' from './endpoints/channels/timeline.js';
export * as 'channels/unfavorite' from './endpoints/channels/unfavorite.js';
export * as 'channels/unfollow' from './endpoints/channels/unfollow.js';
export * as 'channels/update' from './endpoints/channels/update.js';
+export * as 'channels/mute/create' from './endpoints/channels/mute/create.js';
+export * as 'channels/mute/delete' from './endpoints/channels/mute/delete.js';
+export * as 'channels/mute/list' from './endpoints/channels/mute/list.js';
export * as 'charts/active-users' from './endpoints/charts/active-users.js';
export * as 'charts/ap-request' from './endpoints/charts/ap-request.js';
export * as 'charts/drive' from './endpoints/charts/drive.js';
diff --git a/packages/backend/src/server/api/endpoints/antennas/notes.ts b/packages/backend/src/server/api/endpoints/antennas/notes.ts
index b2d9cea03c..c59479d370 100644
--- a/packages/backend/src/server/api/endpoints/antennas/notes.ts
+++ b/packages/backend/src/server/api/endpoints/antennas/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, AntennasRepository } from '@/models/_.js';
import { QueryService } from '@/core/QueryService.js';
@@ -14,6 +15,7 @@ import { IdService } from '@/core/IdService.js';
import { FanoutTimelineService } from '@/core/FanoutTimelineService.js';
import { GlobalEventService } from '@/core/GlobalEventService.js';
import { trackPromise } from '@/misc/promise-tracker.js';
+import { ChannelMutingService } from '@/core/ChannelMutingService.js';
import { ApiError } from '../../error.js';
export const meta = {
@@ -69,6 +71,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
private queryService: QueryService,
private fanoutTimelineService: FanoutTimelineService,
private globalEventService: GlobalEventService,
+ private channelMutingService: ChannelMutingService,
) {
super(meta, paramDef, async (ps, me) => {
const untilId = ps.untilId ?? (ps.untilDate ? this.idService.gen(ps.untilDate!) : null);
@@ -108,6 +111,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 });
+ }));
+ }
+
// NOTE: センシティブ除外の設定はこのエンドポイントでは無視する。
// https://github.com/misskey-dev/misskey/pull/15346#discussion_r1929950255
diff --git a/packages/backend/src/server/api/endpoints/channels/mute/create.ts b/packages/backend/src/server/api/endpoints/channels/mute/create.ts
new file mode 100644
index 0000000000..26ce707c7a
--- /dev/null
+++ b/packages/backend/src/server/api/endpoints/channels/mute/create.ts
@@ -0,0 +1,90 @@
+/*
+ * SPDX-FileCopyrightText: syuilo and misskey-project
+ * SPDX-License-Identifier: AGPL-3.0-only
+ */
+
+import { Inject, Injectable } from '@nestjs/common';
+import { Endpoint } from '@/server/api/endpoint-base.js';
+import type { ChannelsRepository } from '@/models/_.js';
+import { DI } from '@/di-symbols.js';
+import { ApiError } from '@/server/api/error.js';
+import { ChannelMutingService } from '@/core/ChannelMutingService.js';
+
+export const meta = {
+ tags: ['channels', 'mute'],
+
+ requireCredential: true,
+ prohibitMoved: true,
+
+ kind: 'write:channels',
+
+ errors: {
+ noSuchChannel: {
+ message: 'No such Channel.',
+ code: 'NO_SUCH_CHANNEL',
+ id: '7174361e-d58f-31d6-2e7c-6fb830786a3f',
+ },
+
+ alreadyMuting: {
+ message: 'You are already muting that user.',
+ code: 'ALREADY_MUTING_CHANNEL',
+ id: '5a251978-769a-da44-3e89-3931e43bb592',
+ },
+
+ expiresAtIsPast: {
+ message: 'Cannot set past date to "expiresAt".',
+ code: 'EXPIRES_AT_IS_PAST',
+ id: '42b32236-df2c-a45f-fdbf-def67268f749',
+ },
+ },
+} as const;
+
+export const paramDef = {
+ type: 'object',
+ properties: {
+ channelId: { type: 'string', format: 'misskey:id' },
+ expiresAt: {
+ type: 'integer',
+ nullable: true,
+ description: 'A Unix Epoch timestamp that must lie in the future. `null` means an indefinite mute.',
+ },
+ },
+ required: ['channelId'],
+} as const;
+
+@Injectable()
+export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-disable-line import/no-default-export
+ constructor(
+ @Inject(DI.channelsRepository)
+ private channelsRepository: ChannelsRepository,
+ private channelMutingService: ChannelMutingService,
+ ) {
+ super(meta, paramDef, async (ps, me) => {
+ // Check if exists the channel
+ const targetChannel = await this.channelsRepository.findOneBy({ id: ps.channelId });
+ if (!targetChannel) {
+ throw new ApiError(meta.errors.noSuchChannel);
+ }
+
+ // Check if already muting
+ const exist = await this.channelMutingService.isMuted({
+ requestUserId: me.id,
+ targetChannelId: targetChannel.id,
+ });
+ if (exist) {
+ throw new ApiError(meta.errors.alreadyMuting);
+ }
+
+ // Check if expiresAt is past
+ if (ps.expiresAt && ps.expiresAt <= Date.now()) {
+ throw new ApiError(meta.errors.expiresAtIsPast);
+ }
+
+ await this.channelMutingService.mute({
+ requestUserId: me.id,
+ targetChannelId: targetChannel.id,
+ expiresAt: ps.expiresAt ? new Date(ps.expiresAt) : null,
+ });
+ });
+ }
+}
diff --git a/packages/backend/src/server/api/endpoints/channels/mute/delete.ts b/packages/backend/src/server/api/endpoints/channels/mute/delete.ts
new file mode 100644
index 0000000000..79abeebe99
--- /dev/null
+++ b/packages/backend/src/server/api/endpoints/channels/mute/delete.ts
@@ -0,0 +1,73 @@
+/*
+ * SPDX-FileCopyrightText: syuilo and misskey-project
+ * SPDX-License-Identifier: AGPL-3.0-only
+ */
+
+import { Inject, Injectable } from '@nestjs/common';
+import { Endpoint } from '@/server/api/endpoint-base.js';
+import type { ChannelsRepository } from '@/models/_.js';
+import { DI } from '@/di-symbols.js';
+import { ChannelMutingService } from '@/core/ChannelMutingService.js';
+import { ApiError } from '@/server/api/error.js';
+
+export const meta = {
+ tags: ['channels', 'mute'],
+
+ requireCredential: true,
+ prohibitMoved: true,
+
+ kind: 'write:channels',
+
+ errors: {
+ noSuchChannel: {
+ message: 'No such Channel.',
+ code: 'NO_SUCH_CHANNEL',
+ id: 'e7998769-6e94-d9c2-6b8f-94a527314aba',
+ },
+
+ notMuting: {
+ message: 'You are not muting that channel.',
+ code: 'NOT_MUTING_CHANNEL',
+ id: '14d55962-6ea8-d990-1333-d6bef78dc2ab',
+ },
+ },
+} as const;
+
+export const paramDef = {
+ type: 'object',
+ properties: {
+ channelId: { type: 'string', format: 'misskey:id' },
+ },
+ required: ['channelId'],
+} as const;
+
+@Injectable()
+export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-disable-line import/no-default-export
+ constructor(
+ @Inject(DI.channelsRepository)
+ private channelsRepository: ChannelsRepository,
+ private channelMutingService: ChannelMutingService,
+ ) {
+ super(meta, paramDef, async (ps, me) => {
+ // Check if exists the channel
+ const targetChannel = await this.channelsRepository.findOneBy({ id: ps.channelId });
+ if (!targetChannel) {
+ throw new ApiError(meta.errors.noSuchChannel);
+ }
+
+ // Check muting
+ const exist = await this.channelMutingService.isMuted({
+ requestUserId: me.id,
+ targetChannelId: targetChannel.id,
+ });
+ if (!exist) {
+ throw new ApiError(meta.errors.notMuting);
+ }
+
+ await this.channelMutingService.unmute({
+ requestUserId: me.id,
+ targetChannelId: targetChannel.id,
+ });
+ });
+ }
+}
diff --git a/packages/backend/src/server/api/endpoints/channels/mute/list.ts b/packages/backend/src/server/api/endpoints/channels/mute/list.ts
new file mode 100644
index 0000000000..74338eea38
--- /dev/null
+++ b/packages/backend/src/server/api/endpoints/channels/mute/list.ts
@@ -0,0 +1,49 @@
+/*
+ * SPDX-FileCopyrightText: syuilo and misskey-project
+ * SPDX-License-Identifier: AGPL-3.0-only
+ */
+
+import { Injectable } from '@nestjs/common';
+import { Endpoint } from '@/server/api/endpoint-base.js';
+import { ChannelMutingService } from '@/core/ChannelMutingService.js';
+import { ChannelEntityService } from '@/core/entities/ChannelEntityService.js';
+
+export const meta = {
+ tags: ['channels', 'mute'],
+
+ requireCredential: true,
+ prohibitMoved: true,
+
+ kind: 'read:channels',
+
+ res: {
+ type: 'array',
+ optional: false, nullable: false,
+ items: {
+ type: 'object',
+ optional: false, nullable: false,
+ ref: 'Channel',
+ },
+ },
+} as const;
+
+export const paramDef = {
+ type: 'object',
+ properties: {},
+ required: [],
+} as const;
+
+@Injectable()
+export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-disable-line import/no-default-export
+ constructor(
+ private channelMutingService: ChannelMutingService,
+ private channelEntityService: ChannelEntityService,
+ ) {
+ super(meta, paramDef, async (ps, me) => {
+ const mutings = await this.channelMutingService.list({
+ requestUserId: me.id,
+ });
+ return await this.channelEntityService.packMany(mutings, me);
+ });
+ }
+}
diff --git a/packages/backend/src/server/api/endpoints/channels/timeline.ts b/packages/backend/src/server/api/endpoints/channels/timeline.ts
index 46b050d4b4..4f56bc2110 100644
--- a/packages/backend/src/server/api/endpoints/channels/timeline.ts
+++ b/packages/backend/src/server/api/endpoints/channels/timeline.ts
@@ -13,6 +13,7 @@ import { DI } from '@/di-symbols.js';
import { IdService } from '@/core/IdService.js';
import { FanoutTimelineEndpointService } from '@/core/FanoutTimelineEndpointService.js';
import { MiLocalUser } from '@/models/User.js';
+import { ChannelMutingService } from '@/core/ChannelMutingService.js';
import { ApiError } from '../../error.js';
export const meta = {
@@ -70,6 +71,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
private queryService: QueryService,
private fanoutTimelineEndpointService: FanoutTimelineEndpointService,
private activeUsersChart: ActiveUsersChart,
+ private channelMutingService: ChannelMutingService,
) {
super(meta, paramDef, async (ps, me) => {
const untilId = ps.untilId ?? (ps.untilDate ? this.idService.gen(ps.untilDate!) : null);
@@ -98,6 +100,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
useDbFallback: true,
redisTimelines: [`channelTimeline:${channel.id}`],
excludePureRenotes: false,
+ ignoreAuthorChannelFromMute: true,
dbFallback: async (untilId, sinceId, limit) => {
return await this.getFromDb({ untilId, sinceId, limit, channelId: channel.id }, me);
},
@@ -122,6 +125,16 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
.leftJoinAndSelect('note.channel', 'channel');
this.queryService.generateBaseNoteFilteringQuery(query, me);
+
+ if (me) {
+ const mutingChannelIds = await this.channelMutingService
+ .list({ requestUserId: me.id }, { idOnly: true })
+ .then(x => x.map(x => x.id).filter(x => x !== ps.channelId));
+ if (mutingChannelIds.length > 0) {
+ query.andWhere('note.channelId NOT IN (:...mutingChannelIds)', { mutingChannelIds });
+ query.andWhere('note.renoteChannelId NOT IN (:...mutingChannelIds)', { mutingChannelIds });
+ }
+ }
//#endregion
return await query.limit(ps.limit).getMany();
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 2c8459525a..0a3602df20 100644
--- a/packages/backend/src/server/api/endpoints/notes/hybrid-timeline.ts
+++ b/packages/backend/src/server/api/endpoints/notes/hybrid-timeline.ts
@@ -18,6 +18,8 @@ import { QueryService } from '@/core/QueryService.js';
import { UserFollowingService } from '@/core/UserFollowingService.js';
import { MiLocalUser } from '@/models/User.js';
import { FanoutTimelineEndpointService } from '@/core/FanoutTimelineEndpointService.js';
+import { ChannelMutingService } from '@/core/ChannelMutingService.js';
+import { ChannelFollowingService } from '@/core/ChannelFollowingService.js';
import { ApiError } from '../../error.js';
export const meta = {
@@ -46,7 +48,7 @@ export const meta = {
bothWithRepliesAndWithFiles: {
message: 'Specifying both withReplies and withFiles is not supported',
code: 'BOTH_WITH_REPLIES_AND_WITH_FILES',
- id: 'dfaa3eb7-8002-4cb7-bcc4-1095df46656f'
+ id: 'dfaa3eb7-8002-4cb7-bcc4-1095df46656f',
},
},
} as const;
@@ -79,9 +81,6 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
@Inject(DI.notesRepository)
private notesRepository: NotesRepository,
- @Inject(DI.channelFollowingsRepository)
- private channelFollowingsRepository: ChannelFollowingsRepository,
-
private noteEntityService: NoteEntityService,
private roleService: RoleService,
private activeUsersChart: ActiveUsersChart,
@@ -89,6 +88,8 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
private cacheService: CacheService,
private queryService: QueryService,
private userFollowingService: UserFollowingService,
+ private channelMutingService: ChannelMutingService,
+ private channelFollowingService: ChannelFollowingService,
private fanoutTimelineEndpointService: FanoutTimelineEndpointService,
) {
super(meta, paramDef, async (ps, me) => {
@@ -196,11 +197,13 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
withReplies: boolean,
}, me: MiLocalUser) {
const followees = await this.userFollowingService.getFollowees(me.id);
- const followingChannels = await this.channelFollowingsRepository.find({
- where: {
- followerId: me.id,
- },
- });
+
+ const mutingChannelIds = await this.channelMutingService
+ .list({ requestUserId: me.id }, { idOnly: true })
+ .then(x => x.map(x => x.id));
+ const followingChannelIds = await this.channelFollowingService
+ .list({ requestUserId: me.id }, { idOnly: true })
+ .then(x => x.map(x => x.id).filter(x => !mutingChannelIds.includes(x)));
const query = this.queryService.makePaginationQuery(this.notesRepository.createQueryBuilder('note'), ps.sinceId, ps.untilId)
.andWhere(new Brackets(qb => {
@@ -219,9 +222,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
.leftJoinAndSelect('reply.user', 'replyUser')
.leftJoinAndSelect('renote.user', 'renoteUser');
- if (followingChannels.length > 0) {
- const followingChannelIds = followingChannels.map(x => x.followeeId);
-
+ if (followingChannelIds.length > 0) {
query.andWhere(new Brackets(qb => {
qb.where('note.channelId IN (:...followingChannelIds)', { followingChannelIds });
qb.orWhere('note.channelId IS NULL');
@@ -230,6 +231,13 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
query.andWhere('note.channelId IS NULL');
}
+ if (mutingChannelIds.length > 0) {
+ query.andWhere(new Brackets(qb => {
+ qb.orWhere('note.renoteChannelId IS NULL');
+ qb.orWhere('note.renoteChannelId NOT IN (:...mutingChannelIds)', { mutingChannelIds });
+ }));
+ }
+
if (!ps.withReplies) {
query.andWhere(new Brackets(qb => {
qb
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 ee61ab43da..ec9e52cf04 100644
--- a/packages/backend/src/server/api/endpoints/notes/local-timeline.ts
+++ b/packages/backend/src/server/api/endpoints/notes/local-timeline.ts
@@ -15,6 +15,7 @@ import { IdService } from '@/core/IdService.js';
import { QueryService } from '@/core/QueryService.js';
import { MiLocalUser } from '@/models/User.js';
import { FanoutTimelineEndpointService } from '@/core/FanoutTimelineEndpointService.js';
+import { ChannelMutingService } from '@/core/ChannelMutingService.js';
import { ApiError } from '../../error.js';
export const meta = {
@@ -76,6 +77,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
private idService: IdService,
private fanoutTimelineEndpointService: FanoutTimelineEndpointService,
private queryService: QueryService,
+ private channelMutingService: ChannelMutingService,
) {
super(meta, paramDef, async (ps, me) => {
const untilId = ps.untilId ?? (ps.untilDate ? this.idService.gen(ps.untilDate!) : null);
@@ -157,7 +159,19 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
this.queryService.generateVisibilityQuery(query, me);
this.queryService.generateBaseNoteFilteringQuery(query, me);
- if (me) this.queryService.generateMutedUserRenotesQueryForNotes(query, me);
+ if (me) {
+ this.queryService.generateMutedUserRenotesQueryForNotes(query, me);
+
+ const mutedChannelIds = await this.channelMutingService
+ .list({ requestUserId: me.id }, { idOnly: true })
+ .then(x => x.map(x => x.id));
+ if (mutedChannelIds.length > 0) {
+ query.andWhere(new Brackets(qb => {
+ qb.orWhere('note.renoteChannelId IS NULL')
+ .orWhere('note.renoteChannelId NOT IN (:...mutedChannelIds)', { mutedChannelIds });
+ }));
+ }
+ }
if (ps.withFiles) {
query.andWhere('note.fileIds != \'{}\'');
diff --git a/packages/backend/src/server/api/endpoints/notes/timeline.ts b/packages/backend/src/server/api/endpoints/notes/timeline.ts
index eeeb797efc..fe9c412be4 100644
--- a/packages/backend/src/server/api/endpoints/notes/timeline.ts
+++ b/packages/backend/src/server/api/endpoints/notes/timeline.ts
@@ -5,7 +5,7 @@
import { Brackets } from 'typeorm';
import { Inject, Injectable } from '@nestjs/common';
-import type { NotesRepository, ChannelFollowingsRepository, MiMeta } from '@/models/_.js';
+import type { NotesRepository, MiMeta } from '@/models/_.js';
import { Endpoint } from '@/server/api/endpoint-base.js';
import { QueryService } from '@/core/QueryService.js';
import ActiveUsersChart from '@/core/chart/charts/active-users.js';
@@ -16,6 +16,8 @@ import { CacheService } from '@/core/CacheService.js';
import { UserFollowingService } from '@/core/UserFollowingService.js';
import { MiLocalUser } from '@/models/User.js';
import { FanoutTimelineEndpointService } from '@/core/FanoutTimelineEndpointService.js';
+import { ChannelMutingService } from '@/core/ChannelMutingService.js';
+import { ChannelFollowingService } from '@/core/ChannelFollowingService.js';
export const meta = {
tags: ['notes'],
@@ -61,15 +63,14 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
@Inject(DI.notesRepository)
private notesRepository: NotesRepository,
- @Inject(DI.channelFollowingsRepository)
- private channelFollowingsRepository: ChannelFollowingsRepository,
-
private noteEntityService: NoteEntityService,
private activeUsersChart: ActiveUsersChart,
private idService: IdService,
private cacheService: CacheService,
private fanoutTimelineEndpointService: FanoutTimelineEndpointService,
private userFollowingService: UserFollowingService,
+ private channelMutingService: ChannelMutingService,
+ private channelFollowingService: ChannelFollowingService,
private queryService: QueryService,
) {
super(meta, paramDef, async (ps, me) => {
@@ -140,11 +141,13 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
private async getFromDb(ps: { untilId: string | null; sinceId: string | null; limit: number; includeMyRenotes: boolean; includeRenotedMyNotes: boolean; includeLocalRenotes: boolean; withFiles: boolean; withRenotes: boolean; }, me: MiLocalUser) {
const followees = await this.userFollowingService.getFollowees(me.id);
- const followingChannels = await this.channelFollowingsRepository.find({
- where: {
- followerId: me.id,
- },
- });
+
+ const mutingChannelIds = await this.channelMutingService
+ .list({ requestUserId: me.id }, { idOnly: true })
+ .then(x => x.map(x => x.id));
+ const followingChannelIds = await this.channelFollowingService
+ .list({ requestUserId: me.id }, { idOnly: true })
+ .then(x => x.map(x => x.id).filter(x => !mutingChannelIds.includes(x)));
//#region Construct query
const query = this.queryService.makePaginationQuery(this.notesRepository.createQueryBuilder('note'), ps.sinceId, ps.untilId)
@@ -154,15 +157,14 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
.leftJoinAndSelect('reply.user', 'replyUser')
.leftJoinAndSelect('renote.user', 'renoteUser');
- if (followees.length > 0 && followingChannels.length > 0) {
+ if (followees.length > 0 && followingChannelIds.length > 0) {
// ユーザー・チャンネルともにフォローあり
const meOrFolloweeIds = [me.id, ...followees.map(f => f.followeeId)];
- const followingChannelIds = followingChannels.map(x => x.followeeId);
query.andWhere(new Brackets(qb => {
qb
.where(new Brackets(qb2 => {
qb2
- .where('note.userId IN (:...meOrFolloweeIds)', { meOrFolloweeIds: meOrFolloweeIds })
+ .andWhere('note.userId IN (:...meOrFolloweeIds)', { meOrFolloweeIds: meOrFolloweeIds })
.andWhere('note.channelId IS NULL');
}))
.orWhere('note.channelId IN (:...followingChannelIds)', { followingChannelIds });
@@ -170,22 +172,32 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
} else if (followees.length > 0) {
// ユーザーフォローのみ(チャンネルフォローなし)
const meOrFolloweeIds = [me.id, ...followees.map(f => f.followeeId)];
- query
- .andWhere('note.channelId IS NULL')
- .andWhere('note.userId IN (:...meOrFolloweeIds)', { meOrFolloweeIds: meOrFolloweeIds });
- } else if (followingChannels.length > 0) {
+ query.andWhere(new Brackets(qb => {
+ qb
+ .andWhere('note.channelId IS NULL')
+ .andWhere('note.userId IN (:...meOrFolloweeIds)', { meOrFolloweeIds: meOrFolloweeIds });
+ if (mutingChannelIds.length > 0) {
+ qb.andWhere('note.renoteChannelId NOT IN (:...mutingChannelIds)', { mutingChannelIds });
+ }
+ }));
+ } else if (followingChannelIds.length > 0) {
// チャンネルフォローのみ(ユーザーフォローなし)
- const followingChannelIds = followingChannels.map(x => x.followeeId);
query.andWhere(new Brackets(qb => {
qb
+ // renoteChannelIdは見る必要が無い
+ // ・HTLに流れてくるチャンネル=フォローしているチャンネル
+ // ・HTLにフォロー外のチャンネルが流れるのは、フォローしているユーザがそのチャンネル投稿をリノートした場合のみ
+ // つまり、ユーザフォローしてない前提のこのブロックでは見る必要が無い
.where('note.channelId IN (:...followingChannelIds)', { followingChannelIds })
.orWhere('note.userId = :meId', { meId: me.id });
}));
} else {
// フォローなし
- query
- .andWhere('note.channelId IS NULL')
- .andWhere('note.userId = :meId', { meId: me.id });
+ query.andWhere(new Brackets(qb => {
+ qb
+ .andWhere('note.channelId IS NULL')
+ .andWhere('note.userId = :meId', { meId: me.id });
+ }));
}
query.andWhere(new Brackets(qb => {
diff --git a/packages/backend/src/server/api/endpoints/notes/user-list-timeline.ts b/packages/backend/src/server/api/endpoints/notes/user-list-timeline.ts
index 42e80c6ae1..c0c8653f7b 100644
--- a/packages/backend/src/server/api/endpoints/notes/user-list-timeline.ts
+++ b/packages/backend/src/server/api/endpoints/notes/user-list-timeline.ts
@@ -14,6 +14,7 @@ import { IdService } from '@/core/IdService.js';
import { QueryService } from '@/core/QueryService.js';
import { MiLocalUser } from '@/models/User.js';
import { FanoutTimelineEndpointService } from '@/core/FanoutTimelineEndpointService.js';
+import { ChannelMutingService } from '@/core/ChannelMutingService.js';
import { ApiError } from '../../error.js';
export const meta = {
@@ -84,6 +85,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
private idService: IdService,
private fanoutTimelineEndpointService: FanoutTimelineEndpointService,
private queryService: QueryService,
+ private channelMutingService: ChannelMutingService,
) {
super(meta, paramDef, async (ps, me) => {
const untilId = ps.untilId ?? (ps.untilDate ? this.idService.gen(ps.untilDate!) : null);
@@ -187,6 +189,17 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
this.queryService.generateBaseNoteFilteringQuery(query, me);
this.queryService.generateMutedUserRenotesQueryForNotes(query, me);
+ // -- ミュートされたチャンネルのリノート対策
+ const mutedChannelIds = await this.channelMutingService
+ .list({ requestUserId: me.id }, { idOnly: true })
+ .then(x => x.map(x => x.id));
+ if (mutedChannelIds.length > 0) {
+ query.andWhere(new Brackets(qb => {
+ qb.orWhere('note.renoteChannelId IS NULL')
+ .orWhere('note.renoteChannelId NOT IN (:...mutedChannelIds)', { mutedChannelIds });
+ }));
+ }
+
if (ps.includeMyRenotes === false) {
query.andWhere(new Brackets(qb => {
qb.orWhere('note.userId != :meId', { meId: me.id });
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);
diff --git a/packages/backend/src/server/api/endpoints/users/notes.ts b/packages/backend/src/server/api/endpoints/users/notes.ts
index 5832790a61..b9710250cf 100644
--- a/packages/backend/src/server/api/endpoints/users/notes.ts
+++ b/packages/backend/src/server/api/endpoints/users/notes.ts
@@ -16,6 +16,7 @@ import { MiLocalUser } from '@/models/User.js';
import { FanoutTimelineEndpointService } from '@/core/FanoutTimelineEndpointService.js';
import { FanoutTimelineName } from '@/core/FanoutTimelineService.js';
import { ApiError } from '@/server/api/error.js';
+import { ChannelMutingService } from '@/core/ChannelMutingService.js';
export const meta = {
tags: ['users', 'notes'],
@@ -77,12 +78,12 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
@Inject(DI.notesRepository)
private notesRepository: NotesRepository,
-
private noteEntityService: NoteEntityService,
private queryService: QueryService,
private cacheService: CacheService,
private idService: IdService,
private fanoutTimelineEndpointService: FanoutTimelineEndpointService,
+ private channelMutingService: ChannelMutingService,
) {
super(meta, paramDef, async (ps, me) => {
const untilId = ps.untilId ?? (ps.untilDate ? this.idService.gen(ps.untilDate!) : null);
@@ -165,6 +166,11 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
withFiles: boolean,
withRenotes: boolean,
}, me: MiLocalUser | null) {
+ const mutingChannelIds = me
+ ? await this.channelMutingService
+ .list({ requestUserId: me.id }, { idOnly: true })
+ .then(x => x.map(x => x.id))
+ : [];
const isSelf = me && (me.id === ps.userId);
const query = this.queryService.makePaginationQuery(this.notesRepository.createQueryBuilder('note'), ps.sinceId, ps.untilId)
@@ -177,14 +183,30 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
.leftJoinAndSelect('renote.user', 'renoteUser');
if (ps.withChannelNotes) {
- if (!isSelf) query.andWhere(new Brackets(qb => {
- qb.orWhere('note.channelId IS NULL');
- qb.orWhere('channel.isSensitive = false');
+ query.andWhere(new Brackets(qb => {
+ if (mutingChannelIds.length > 0) {
+ qb.andWhere('note.channelId NOT IN (:...mutingChannelIds)', { mutingChannelIds: mutingChannelIds });
+ }
+
+ if (!isSelf) {
+ qb.andWhere(new Brackets(qb2 => {
+ qb2.orWhere('note.channelId IS NULL');
+ qb2.orWhere('channel.isSensitive = false');
+ }));
+ }
}));
} else {
query.andWhere('note.channelId IS NULL');
}
+ // -- ミュートされたチャンネルのリノート対策
+ if (mutingChannelIds.length > 0) {
+ 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, {
excludeAuthor: true,
diff --git a/packages/backend/src/server/api/stream/Connection.ts b/packages/backend/src/server/api/stream/Connection.ts
index 8e28ab263b..222086c960 100644
--- a/packages/backend/src/server/api/stream/Connection.ts
+++ b/packages/backend/src/server/api/stream/Connection.ts
@@ -11,8 +11,9 @@ import type { NotificationService } from '@/core/NotificationService.js';
import { bindThis } from '@/decorators.js';
import { CacheService } from '@/core/CacheService.js';
import { MiFollowing, MiUserProfile } from '@/models/_.js';
-import type { StreamEventEmitter, GlobalEvents } from '@/core/GlobalEventService.js';
+import type { GlobalEvents, StreamEventEmitter } from '@/core/GlobalEventService.js';
import { ChannelFollowingService } from '@/core/ChannelFollowingService.js';
+import { ChannelMutingService } from '@/core/ChannelMutingService.js';
import { isJsonObject } from '@/misc/json-value.js';
import type { JsonObject, JsonValue } from '@/misc/json-value.js';
import type { ChannelsService } from './ChannelsService.js';
@@ -35,6 +36,7 @@ export default class Connection {
public userProfile: MiUserProfile | null = null;
public following: Record<string, Pick<MiFollowing, 'withReplies'> | undefined> = {};
public followingChannels: Set<string> = new Set();
+ public mutingChannels: Set<string> = new Set();
public userIdsWhoMeMuting: Set<string> = new Set();
public userIdsWhoBlockingMe: Set<string> = new Set();
public userIdsWhoMeMutingRenotes: Set<string> = new Set();
@@ -46,7 +48,7 @@ export default class Connection {
private notificationService: NotificationService,
private cacheService: CacheService,
private channelFollowingService: ChannelFollowingService,
-
+ private channelMutingService: ChannelMutingService,
user: MiUser | null | undefined,
token: MiAccessToken | null | undefined,
) {
@@ -57,10 +59,19 @@ export default class Connection {
@bindThis
public async fetch() {
if (this.user == null) return;
- const [userProfile, following, followingChannels, userIdsWhoMeMuting, userIdsWhoBlockingMe, userIdsWhoMeMutingRenotes] = await Promise.all([
+ const [
+ userProfile,
+ following,
+ followingChannels,
+ mutingChannels,
+ userIdsWhoMeMuting,
+ userIdsWhoBlockingMe,
+ userIdsWhoMeMutingRenotes,
+ ] = await Promise.all([
this.cacheService.userProfileCache.fetch(this.user.id),
this.cacheService.userFollowingsCache.fetch(this.user.id),
this.channelFollowingService.userFollowingChannelsCache.fetch(this.user.id),
+ this.channelMutingService.mutingChannelsCache.fetch(this.user.id),
this.cacheService.userMutingsCache.fetch(this.user.id),
this.cacheService.userBlockedCache.fetch(this.user.id),
this.cacheService.renoteMutingsCache.fetch(this.user.id),
@@ -68,6 +79,7 @@ export default class Connection {
this.userProfile = userProfile;
this.following = following;
this.followingChannels = followingChannels;
+ this.mutingChannels = mutingChannels;
this.userIdsWhoMeMuting = userIdsWhoMeMuting;
this.userIdsWhoBlockingMe = userIdsWhoBlockingMe;
this.userIdsWhoMeMutingRenotes = userIdsWhoMeMutingRenotes;
diff --git a/packages/backend/src/server/api/stream/channel.ts b/packages/backend/src/server/api/stream/channel.ts
index 686aea423c..465ed4238c 100644
--- a/packages/backend/src/server/api/stream/channel.ts
+++ b/packages/backend/src/server/api/stream/channel.ts
@@ -6,7 +6,8 @@
import { bindThis } from '@/decorators.js';
import { isInstanceMuted } from '@/misc/is-instance-muted.js';
import { isUserRelated } from '@/misc/is-user-related.js';
-import { isRenotePacked, isQuotePacked } from '@/misc/is-renote.js';
+import { isQuotePacked, isRenotePacked } from '@/misc/is-renote.js';
+import { isChannelRelated } from '@/misc/is-channel-related.js';
import type { Packed } from '@/misc/json-schema.js';
import type { JsonObject, JsonValue } from '@/misc/json-value.js';
import type Connection from './Connection.js';
@@ -55,6 +56,10 @@ export default abstract class Channel {
return this.connection.followingChannels;
}
+ protected get mutingChannels() {
+ return this.connection.mutingChannels;
+ }
+
protected get subscriber() {
return this.connection.subscriber;
}
@@ -74,6 +79,9 @@ export default abstract class Channel {
// 流れてきたNoteがリノートをミュートしてるユーザが行ったもの
if (isRenotePacked(note) && !isQuotePacked(note) && this.userIdsWhoMeMutingRenotes.has(note.user.id)) return true;
+ // 流れてきたNoteがミュートしているチャンネルと関わる
+ if (isChannelRelated(note, this.mutingChannels)) return true;
+
return false;
}
diff --git a/packages/backend/src/server/api/stream/channels/channel.ts b/packages/backend/src/server/api/stream/channels/channel.ts
index ac79c31854..9a0da5b66b 100644
--- a/packages/backend/src/server/api/stream/channels/channel.ts
+++ b/packages/backend/src/server/api/stream/channels/channel.ts
@@ -8,6 +8,8 @@ import type { Packed } from '@/misc/json-schema.js';
import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
import { bindThis } from '@/decorators.js';
import { isRenotePacked, isQuotePacked } from '@/misc/is-renote.js';
+import { isInstanceMuted } from '@/misc/is-instance-muted.js';
+import { isUserRelated } from '@/misc/is-user-related.js';
import type { JsonObject } from '@/misc/json-value.js';
import Channel, { type MiChannelService } from '../channel.js';
@@ -19,7 +21,6 @@ class ChannelChannel extends Channel {
constructor(
private noteEntityService: NoteEntityService,
-
id: string,
connection: Channel['connection'],
) {
@@ -52,6 +53,35 @@ class ChannelChannel extends Channel {
this.send('note', note);
}
+ /*
+ * ミュートとブロックされてるを処理する
+ */
+ protected override isNoteMutedOrBlocked(note: Packed<'Note'>): boolean {
+ // 流れてきたNoteがインスタンスミュートしたインスタンスが関わる
+ if (isInstanceMuted(note, new Set<string>(this.userProfile?.mutedInstances ?? []))) return true;
+
+ // 流れてきたNoteがミュートしているユーザーが関わる
+ if (isUserRelated(note, this.userIdsWhoMeMuting)) return true;
+ // 流れてきたNoteがブロックされているユーザーが関わる
+ if (isUserRelated(note, this.userIdsWhoBlockingMe)) return true;
+
+ // 流れてきたNoteがリノートをミュートしてるユーザが行ったもの
+ if (isRenotePacked(note) && !isQuotePacked(note) && this.userIdsWhoMeMutingRenotes.has(note.user.id)) return true;
+
+ // このソケットで見ているチャンネルがミュートされていたとしても、チャンネルを直接見ている以上は流すようにしたい
+ // ただし、他のミュートしているチャンネルは流さないようにもしたい
+ // ノート自体のチャンネルIDはonNoteでチェックしているので、ここではリノートのチャンネルIDをチェックする
+ if (
+ (note.renote) &&
+ (note.renote.channelId !== this.channelId) &&
+ (note.renote.channelId && this.mutingChannels.has(note.renote.channelId))
+ ) {
+ return true;
+ }
+
+ return false;
+ }
+
@bindThis
public dispose() {
// Unsubscribe events
diff --git a/packages/backend/src/server/api/stream/channels/home-timeline.ts b/packages/backend/src/server/api/stream/channels/home-timeline.ts
index 157d9fc279..eb5b4a8c6c 100644
--- a/packages/backend/src/server/api/stream/channels/home-timeline.ts
+++ b/packages/backend/src/server/api/stream/channels/home-timeline.ts
@@ -44,7 +44,10 @@ class HomeTimelineChannel extends Channel {
if (this.withFiles && (note.fileIds == null || note.fileIds.length === 0)) return;
if (note.channelId) {
- if (!this.followingChannels.has(note.channelId)) return;
+ // そのチャンネルをフォローしていない
+ if (!this.followingChannels.has(note.channelId)) {
+ return;
+ }
} else {
// その投稿のユーザーをフォローしていなかったら弾く
if (!isMe && !Object.hasOwn(this.following, note.userId)) return;
diff --git a/packages/backend/src/server/api/stream/channels/hybrid-timeline.ts b/packages/backend/src/server/api/stream/channels/hybrid-timeline.ts
index db5b4576be..2155e02012 100644
--- a/packages/backend/src/server/api/stream/channels/hybrid-timeline.ts
+++ b/packages/backend/src/server/api/stream/channels/hybrid-timeline.ts
@@ -53,16 +53,25 @@ class HybridTimelineChannel extends Channel {
if (this.withFiles && (note.fileIds == null || note.fileIds.length === 0)) return;
- // チャンネルの投稿ではなく、自分自身の投稿 または
- // チャンネルの投稿ではなく、その投稿のユーザーをフォローしている または
- // チャンネルの投稿ではなく、全体公開のローカルの投稿 または
- // フォローしているチャンネルの投稿 の場合だけ
- if (!(
- (note.channelId == null && isMe) ||
- (note.channelId == null && Object.hasOwn(this.following, note.userId)) ||
- (note.channelId == null && (note.user.host == null && note.visibility === 'public')) ||
- (note.channelId != null && this.followingChannels.has(note.channelId))
- )) return;
+ if (!note.channelId) {
+ // 以下の条件に該当するノートのみ後続処理に通す(ので、以下のif文は該当しないノートをすべて弾くようにする)
+ // - 自分自身の投稿
+ // - その投稿のユーザーをフォローしている
+ // - 全体公開のローカルの投稿
+ if (!(
+ isMe ||
+ Object.hasOwn(this.following, note.userId) ||
+ (note.user.host == null && note.visibility === 'public')
+ )) {
+ return;
+ }
+ } else {
+ // 以下の条件に該当するノートのみ後続処理に通す(ので、以下のif文は該当しないノートをすべて弾くようにする)
+ // - フォローしているチャンネルの投稿
+ if (!this.followingChannels.has(note.channelId)) {
+ return;
+ }
+ }
if (note.visibility === 'followers') {
if (!isMe && !Object.hasOwn(this.following, note.userId)) return;
diff --git a/packages/backend/test/e2e/antennas.ts b/packages/backend/test/e2e/antennas.ts
index 1bbacd065b..70a5c9579e 100644
--- a/packages/backend/test/e2e/antennas.ts
+++ b/packages/backend/test/e2e/antennas.ts
@@ -69,6 +69,9 @@ describe('アンテナ', () => {
let userMutingAlice: User;
let userMutedByAlice: User;
+ let testChannel: misskey.entities.Channel;
+ let testMutedChannel: misskey.entities.Channel;
+
beforeAll(async () => {
root = await signup({ username: 'root' });
alice = await signup({ username: 'alice' });
@@ -120,6 +123,10 @@ describe('アンテナ', () => {
userMutedByAlice = await signup({ username: 'userMutedByAlice' });
await post(userMutedByAlice, { text: 'test' });
await api('mute/create', { userId: userMutedByAlice.id }, alice);
+
+ testChannel = (await api('channels/create', { name: 'test' }, root)).body;
+ testMutedChannel = (await api('channels/create', { name: 'test-muted' }, root)).body;
+ await api('channels/mute/create', { channelId: testMutedChannel.id }, alice);
}, 1000 * 60 * 10);
beforeEach(async () => {
@@ -605,6 +612,20 @@ describe('アンテナ', () => {
{ note: (): Promise<Note> => post(bob, { text: `${keyword}` }), included: true },
],
},
+ {
+ label: 'チャンネルノートも含む',
+ parameters: () => ({ src: 'all' }),
+ posts: [
+ { note: (): Promise<Note> => post(bob, { text: `test ${keyword}`, channelId: testChannel.id }), included: true },
+ ],
+ },
+ {
+ label: 'ミュートしてるチャンネルは含まない',
+ parameters: () => ({ src: 'all' }),
+ posts: [
+ { note: (): Promise<Note> => post(bob, { text: `test ${keyword}`, channelId: testMutedChannel.id }) },
+ ],
+ },
])('が取得できること($label)', async ({ parameters, posts }) => {
const antenna = await successfulApiCall({
endpoint: 'antennas/create',
diff --git a/packages/backend/test/e2e/timelines.ts b/packages/backend/test/e2e/timelines.ts
index 4f7d1a4d69..4fd826100d 100644
--- a/packages/backend/test/e2e/timelines.ts
+++ b/packages/backend/test/e2e/timelines.ts
@@ -3,14 +3,17 @@
* SPDX-License-Identifier: AGPL-3.0-only
*/
+/* eslint-disable @typescript-eslint/no-explicit-any */
+
// How to run:
// pnpm jest -- e2e/timelines.ts
import * as assert from 'assert';
import { setTimeout } from 'node:timers/promises';
+import { entities } from 'misskey-js';
import { Redis } from 'ioredis';
-import { SignupResponse, Note, UserList } from 'misskey-js/entities.js';
-import { api, post, randomString, sendEnvUpdateRequest, signup, uploadUrl } from '../utils.js';
+import { SignupResponse, Note } from 'misskey-js/entities.js';
+import { api, initTestDb, post, randomString, sendEnvUpdateRequest, signup, uploadUrl, UserToken } from '../utils.js';
import { loadConfig } from '@/config.js';
function genHost() {
@@ -20,12 +23,72 @@ function genHost() {
let redisForTimelines: Redis;
let root: SignupResponse;
+async function renote(noteId: string, user: UserToken): Promise<entities.Note> {
+ return await api('notes/create', { renoteId: noteId }, user).then(it => it.body.createdNote);
+}
+
+async function createChannel(name: string, user: UserToken): Promise<entities.ChannelsCreateResponse> {
+ return (await api('channels/create', { name }, user)).body;
+}
+
+async function followChannel(channelId: string, user: UserToken) {
+ return await api('channels/follow', { channelId }, user);
+}
+
+async function muteChannel(channelId: string, user: UserToken) {
+ await api('channels/mute/create', { channelId }, user);
+}
+
+async function createList(name: string, user: UserToken): Promise<entities.UsersListsCreateResponse> {
+ return (await api('users/lists/create', { name }, user)).body;
+}
+
+async function pushList(listId: string, pushUserIds: string[] = [], user: UserToken) {
+ for (const userId of pushUserIds) {
+ await api('users/lists/push', { listId, userId }, user);
+ }
+ await setTimeout(500);
+}
+
+async function createRole(name: string, user: UserToken): Promise<entities.AdminRolesCreateResponse> {
+ return (await api('admin/roles/create', {
+ name,
+ description: '',
+ color: '#000000',
+ iconUrl: '',
+ target: 'manual',
+ condFormula: {},
+ isPublic: true,
+ isModerator: false,
+ isAdministrator: false,
+ isExplorable: true,
+ asBadge: false,
+ canEditMembersByModerator: false,
+ displayOrder: 0,
+ policies: {},
+ }, user)).body;
+}
+
+async function assignRole(roleId: string, userId: string, user: UserToken) {
+ await api('admin/roles/assign', { userId, roleId }, user);
+}
+
describe('Timelines', () => {
+ let root: UserToken;
+
beforeAll(async () => {
redisForTimelines = new Redis(loadConfig().redisForTimelines);
root = await signup({ username: 'root' });
}, 1000 * 60 * 2);
+ // afterEach(async () => {
+ // // テスト中に作ったノートをきれいにする。
+ // // ユーザも作っているが、時間差で動く通知系処理などがあり、このタイミングで消すとエラー落ちするので消さない(ノートさえ消えていれば支障はない)
+ // const db = await initTestDb(true);
+ // await db.query('DELETE FROM "note"');
+ // await db.query('DELETE FROM "channel"');
+ // });
+
describe.each([
{ enableFanoutTimeline: true },
{ enableFanoutTimeline: false },
@@ -611,6 +674,280 @@ describe('Timelines', () => {
assert.strictEqual(res.body.some(note => note.id === bobNote.id), false);
});
+ describe('Channel', () => {
+ test('チャンネル未フォロー + ユーザ未フォロー = TLに流れない', async () => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
+
+ const channel = await createChannel('channel', bob);
+
+ const aliceNote = await post(alice, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
+
+ await waitForPushToTl();
+
+ const res = await api('notes/timeline', { limit: 100 }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false);
+ });
+
+ test('チャンネルフォロー + ユーザ未フォロー = TLに流れる', async () => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
+
+ const channel = await createChannel('channel', bob);
+ await followChannel(channel.id, alice);
+
+ const aliceNote = await post(alice, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
+
+ await waitForPushToTl();
+
+ const res = await api('notes/timeline', { limit: 100 }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), true);
+ });
+
+ test('チャンネル未フォロー + ユーザフォロー = TLに流れない', async () => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
+ await api('following/create', { userId: bob.id }, alice);
+
+ const channel = await createChannel('channel', bob);
+
+ const aliceNote = await post(alice, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
+
+ await waitForPushToTl();
+
+ const res = await api('notes/timeline', { limit: 100 }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false);
+ });
+
+ test('チャンネルフォロー + ユーザフォロー = TLに流れる', async () => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
+ await api('following/create', { userId: bob.id }, alice);
+
+ const channel = await createChannel('channel', bob);
+ await followChannel(channel.id, alice);
+
+ const aliceNote = await post(alice, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
+
+ await waitForPushToTl();
+
+ const res = await api('notes/timeline', { limit: 100 }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), true);
+ });
+
+ test('チャンネル未フォロー + ユーザ未フォロー + チャンネルミュート = TLに流れない', async () => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
+
+ const channel = await createChannel('channel', bob);
+ await muteChannel(channel.id, alice);
+
+ const aliceNote = await post(alice, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
+
+ await waitForPushToTl();
+
+ const res = await api('notes/timeline', { limit: 100 }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false);
+ });
+
+ test('チャンネルフォロー + ユーザ未フォロー + チャンネルミュート = TLに流れない', async () => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
+
+ const channel = await createChannel('channel', bob);
+ await followChannel(channel.id, alice);
+ await muteChannel(channel.id, alice);
+
+ const aliceNote = await post(alice, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
+
+ await waitForPushToTl();
+
+ const res = await api('notes/timeline', { limit: 100 }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false);
+ });
+
+ test('チャンネル未フォロー + ユーザフォロー + チャンネルミュート = TLに流れない', async () => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
+ await api('following/create', { userId: bob.id }, alice);
+
+ const channel = await createChannel('channel', bob);
+ await muteChannel(channel.id, alice);
+
+ const aliceNote = await post(alice, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
+
+ await waitForPushToTl();
+
+ const res = await api('notes/timeline', { limit: 100 }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false);
+ });
+
+ test('チャンネルフォロー + ユーザフォロー + チャンネルミュート = TLに流れない', async () => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
+ await api('following/create', { userId: bob.id }, alice);
+
+ const channel = await createChannel('channel', bob);
+ await followChannel(channel.id, alice);
+ await muteChannel(channel.id, alice);
+
+ const aliceNote = await post(alice, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
+
+ await waitForPushToTl();
+
+ const res = await api('notes/timeline', { limit: 100 }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false);
+ });
+
+ test('[チャンネル外リノート] チャンネル未フォロー + ユーザ未フォロー = TLに流れない', async () => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
+
+ const channel = await createChannel('channel', bob);
+
+ const aliceNote = await post(alice, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
+ const bobRenote = await renote(bobNote.id, bob);
+
+ await waitForPushToTl();
+
+ const res = await api('notes/timeline', { limit: 100 }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === bobRenote.id), false);
+ });
+
+ test('[チャンネル外リノート] チャンネルフォロー + ユーザ未フォロー = TLに流れない', async () => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
+
+ const channel = await createChannel('channel', bob);
+ await followChannel(channel.id, alice);
+
+ const aliceNote = await post(alice, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
+ const bobRenote = await renote(bobNote.id, bob);
+
+ await waitForPushToTl();
+
+ const res = await api('notes/timeline', { limit: 100 }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === bobRenote.id), false);
+ });
+
+ test('[チャンネル外リノート] チャンネル未フォロー + ユーザフォロー = TLに流れる', async () => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
+ await api('following/create', { userId: bob.id }, alice);
+
+ const channel = await createChannel('channel', bob);
+
+ const aliceNote = await post(alice, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
+ const bobRenote = await renote(bobNote.id, bob);
+
+ await waitForPushToTl();
+
+ const res = await api('notes/timeline', { limit: 100 }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === bobRenote.id), true);
+ });
+
+ test('[チャンネル外リノート] チャンネルフォロー + ユーザフォロー = TLに流れる', async () => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
+ await api('following/create', { userId: bob.id }, alice);
+
+ const channel = await createChannel('channel', bob);
+ await followChannel(channel.id, alice);
+
+ const aliceNote = await post(alice, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
+ const bobRenote = await renote(bobNote.id, bob);
+
+ await waitForPushToTl();
+
+ const res = await api('notes/timeline', { limit: 100 }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === bobRenote.id), true);
+ });
+
+ test('[チャンネル外リノート] チャンネル未フォロー + ユーザ未フォロー + チャンネルミュート = TLに流れない', async () => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
+
+ const channel = await createChannel('channel', bob);
+ await muteChannel(channel.id, alice);
+
+ const aliceNote = await post(alice, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
+ const bobRenote = await renote(bobNote.id, bob);
+
+ await waitForPushToTl();
+
+ const res = await api('notes/timeline', { limit: 100 }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === bobRenote.id), false);
+ });
+
+ test('[チャンネル外リノート] チャンネルフォロー + ユーザ未フォロー + チャンネルミュート = TLに流れない', async () => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
+
+ const channel = await createChannel('channel', bob);
+ await followChannel(channel.id, alice);
+ await muteChannel(channel.id, alice);
+
+ const aliceNote = await post(alice, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
+ const bobRenote = await renote(bobNote.id, bob);
+
+ await waitForPushToTl();
+
+ const res = await api('notes/timeline', { limit: 100 }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === bobRenote.id), false);
+ });
+
+ test('[チャンネル外リノート] チャンネル未フォロー + ユーザフォロー + チャンネルミュート = TLに流れない', async () => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
+ await api('following/create', { userId: bob.id }, alice);
+
+ const channel = await createChannel('channel', bob);
+ await muteChannel(channel.id, alice);
+
+ const aliceNote = await post(alice, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
+ const bobRenote = await renote(bobNote.id, bob);
+
+ await waitForPushToTl();
+
+ const res = await api('notes/timeline', { limit: 100 }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === bobRenote.id), false);
+ });
+
+ test('[チャンネル外リノート] チャンネルフォロー + ユーザフォロー + チャンネルミュート = TLに流れない', async () => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
+ await api('following/create', { userId: bob.id }, alice);
+
+ const channel = await createChannel('channel', bob);
+ await followChannel(channel.id, alice);
+ await muteChannel(channel.id, alice);
+
+ const aliceNote = await post(alice, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
+ const bobRenote = await renote(bobNote.id, bob);
+
+ await waitForPushToTl();
+
+ const res = await api('notes/timeline', { limit: 100 }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === bobRenote.id), false);
+ });
+ });
+
test('FTT: ローカルユーザーの HTL にはプッシュされる', async () => {
const [alice, bob, carol] = await Promise.all([signup(), signup(), signup()]);
@@ -1012,41 +1349,277 @@ describe('Timelines', () => {
assert.strictEqual(res.body.some(note => note.id === bobNote2.id), true);
}, 1000 * 10);
- describe('凍結', () => {
- let alice: SignupResponse, bob: SignupResponse, carol: SignupResponse;
- let aliceNote: Note, bobNote: Note, carolNote: Note;
+ describe('Channel', () => {
+ test('チャンネル未フォロー + ユーザ未フォロー = TLに流れない', async () => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
- beforeAll(async () => {
- [alice, bob, carol] = await Promise.all([signup(), signup(), signup()]);
+ const channel = await createChannel('channel', bob);
- aliceNote = await post(alice, { text: 'hi' });
- bobNote = await post(bob, { text: 'yo' });
- carolNote = await post(carol, { text: 'kon\'nichiwa' });
+ const aliceNote = await post(alice, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
await waitForPushToTl();
+
+ const res = await api('notes/local-timeline', { limit: 100 }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false);
});
- test('凍結後に凍結されたユーザーのノートは見えなくなる', async () => {
- await api('admin/suspend-user', { userId: carol.id }, root);
- await setTimeout(100);
+ test('チャンネルフォロー + ユーザ未フォロー = TLに流れない', async () => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
+
+ const channel = await createChannel('channel', bob);
+ await followChannel(channel.id, alice);
+
+ const aliceNote = await post(alice, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
+
+ await waitForPushToTl();
const res = await api('notes/local-timeline', { limit: 100 }, alice);
- assert.strictEqual(res.body.some(note => note.id === aliceNote.id), true);
- assert.strictEqual(res.body.some(note => note.id === bobNote.id), true);
- assert.strictEqual(res.body.some(note => note.id === carolNote.id), false);
+ assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false);
});
- test('凍結解除後に凍結されていたユーザーのノートは見えるようになる', async () => {
- await api('admin/unsuspend-user', { userId: carol.id }, root);
- await setTimeout(100);
+ test('チャンネル未フォロー + ユーザフォロー = TLに流れない', async () => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
+ await api('following/create', { userId: bob.id }, alice);
+
+ const channel = await createChannel('channel', bob);
+
+ const aliceNote = await post(alice, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
+
+ await waitForPushToTl();
const res = await api('notes/local-timeline', { limit: 100 }, alice);
- assert.strictEqual(res.body.some(note => note.id === aliceNote.id), true);
- assert.strictEqual(res.body.some(note => note.id === bobNote.id), true);
- assert.strictEqual(res.body.some(note => note.id === carolNote.id), true);
- assert.strictEqual(res.body.find(note => note.id === carolNote.id)?.text, 'kon\'nichiwa');
+ assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false);
+ });
+
+ test('チャンネルフォロー + ユーザフォロー = TLに流れない', async () => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
+ await api('following/create', { userId: bob.id }, alice);
+
+ const channel = await createChannel('channel', bob);
+ await followChannel(channel.id, alice);
+
+ const aliceNote = await post(alice, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
+
+ await waitForPushToTl();
+
+ const res = await api('notes/local-timeline', { limit: 100 }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false);
+ });
+
+ test('チャンネル未フォロー + ユーザ未フォロー + チャンネルミュート = TLに流れない', async () => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
+
+ const channel = await createChannel('channel', bob);
+ await muteChannel(channel.id, alice);
+
+ const aliceNote = await post(alice, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
+
+ await waitForPushToTl();
+
+ const res = await api('notes/local-timeline', { limit: 100 }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false);
+ });
+
+ test('チャンネルフォロー + ユーザ未フォロー + チャンネルミュート = TLに流れない', async () => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
+
+ const channel = await createChannel('channel', bob);
+ await followChannel(channel.id, alice);
+ await muteChannel(channel.id, alice);
+
+ const aliceNote = await post(alice, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
+
+ await waitForPushToTl();
+
+ const res = await api('notes/local-timeline', { limit: 100 }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false);
+ });
+
+ test('チャンネル未フォロー + ユーザフォロー + チャンネルミュート = TLに流れない', async () => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
+ await api('following/create', { userId: bob.id }, alice);
+
+ const channel = await createChannel('channel', bob);
+ await muteChannel(channel.id, alice);
+
+ const aliceNote = await post(alice, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
+
+ await waitForPushToTl();
+
+ const res = await api('notes/local-timeline', { limit: 100 }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false);
+ });
+
+ test('チャンネルフォロー + ユーザフォロー + チャンネルミュート = TLに流れない', async () => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
+ await api('following/create', { userId: bob.id }, alice);
+
+ const channel = await createChannel('channel', bob);
+ await followChannel(channel.id, alice);
+ await muteChannel(channel.id, alice);
+
+ const aliceNote = await post(alice, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
+
+ await waitForPushToTl();
+
+ const res = await api('notes/local-timeline', { limit: 100 }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false);
+ });
+
+ test('[チャンネル外リノート] チャンネル未フォロー + ユーザ未フォロー = TLに流れる', async () => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
+
+ const channel = await createChannel('channel', bob);
+
+ const aliceNote = await post(alice, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
+ const bobRenote = await renote(bobNote.id, bob);
+
+ await waitForPushToTl();
+
+ const res = await api('notes/local-timeline', { limit: 100 }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === bobRenote.id), true);
+ });
+
+ test('[チャンネル外リノート] チャンネルフォロー + ユーザ未フォロー = TLに流れる', async () => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
+
+ const channel = await createChannel('channel', bob);
+ await followChannel(channel.id, alice);
+
+ const aliceNote = await post(alice, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
+ const bobRenote = await renote(bobNote.id, bob);
+
+ await waitForPushToTl();
+
+ const res = await api('notes/local-timeline', { limit: 100 }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === bobRenote.id), true);
+ });
+
+ test('[チャンネル外リノート] チャンネル未フォロー + ユーザフォロー = TLに流れる', async () => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
+ await api('following/create', { userId: bob.id }, alice);
+
+ const channel = await createChannel('channel', bob);
+
+ const aliceNote = await post(alice, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
+ const bobRenote = await renote(bobNote.id, bob);
+
+ await waitForPushToTl();
+
+ const res = await api('notes/local-timeline', { limit: 100 }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === bobRenote.id), true);
+ });
+
+ test('[チャンネル外リノート] チャンネルフォロー + ユーザフォロー = TLに流れる', async () => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
+ await api('following/create', { userId: bob.id }, alice);
+
+ const channel = await createChannel('channel', bob);
+ await followChannel(channel.id, alice);
+
+ const aliceNote = await post(alice, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
+ const bobRenote = await renote(bobNote.id, bob);
+
+ await waitForPushToTl();
+
+ const res = await api('notes/local-timeline', { limit: 100 }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === bobRenote.id), true);
+ });
+
+ test('[チャンネル外リノート] チャンネル未フォロー + ユーザ未フォロー + チャンネルミュート = TLに流れない', async () => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
+
+ const channel = await createChannel('channel', bob);
+ await muteChannel(channel.id, alice);
+
+ const aliceNote = await post(alice, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
+ const bobRenote = await renote(bobNote.id, bob);
+
+ await waitForPushToTl();
+
+ const res = await api('notes/local-timeline', { limit: 100 }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === bobRenote.id), false);
+ });
+
+ test('[チャンネル外リノート] チャンネルフォロー + ユーザ未フォロー + チャンネルミュート = TLに流れない', async () => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
+
+ const channel = await createChannel('channel', bob);
+ await followChannel(channel.id, alice);
+ await muteChannel(channel.id, alice);
+
+ const aliceNote = await post(alice, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
+ const bobRenote = await renote(bobNote.id, bob);
+
+ await waitForPushToTl();
+
+ const res = await api('notes/local-timeline', { limit: 100 }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === bobRenote.id), false);
+ });
+
+ test('[チャンネル外リノート] チャンネル未フォロー + ユーザフォロー + チャンネルミュート = TLに流れない', async () => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
+ await api('following/create', { userId: bob.id }, alice);
+
+ const channel = await createChannel('channel', bob);
+ await muteChannel(channel.id, alice);
+
+ const aliceNote = await post(alice, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
+ const bobRenote = await renote(bobNote.id, bob);
+
+ await waitForPushToTl();
+
+ const res = await api('notes/local-timeline', { limit: 100 }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === bobRenote.id), false);
+ });
+
+ test('[チャンネル外リノート] チャンネルフォロー + ユーザフォロー + チャンネルミュート = TLに流れない', async () => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
+ await api('following/create', { userId: bob.id }, alice);
+
+ const channel = await createChannel('channel', bob);
+ await followChannel(channel.id, alice);
+ await muteChannel(channel.id, alice);
+
+ const aliceNote = await post(alice, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
+ const bobRenote = await renote(bobNote.id, bob);
+
+ await waitForPushToTl();
+
+ const res = await api('notes/local-timeline', { limit: 100 }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === bobRenote.id), false);
});
});
});
@@ -1091,7 +1664,8 @@ describe('Timelines', () => {
});
test('withReplies: false でフォローしているユーザーからの自分への返信が含まれる', async () => {
- /* FIXME: https://github.com/misskey-dev/misskey/issues/12065 */ if (!enableFanoutTimeline) return;
+ /* FIXME: https://github.com/misskey-dev/misskey/issues/12065 */
+ if (!enableFanoutTimeline) return;
const [alice, bob] = await Promise.all([signup(), signup()]);
@@ -1127,7 +1701,8 @@ describe('Timelines', () => {
});
test('withReplies: true でフォローしているユーザーの行った別のフォローしているユーザーの visibility: followers な投稿への返信が含まれる', async () => {
- /* FIXME: https://github.com/misskey-dev/misskey/issues/12065 */ if (!enableFanoutTimeline) return;
+ /* FIXME: https://github.com/misskey-dev/misskey/issues/12065 */
+ if (!enableFanoutTimeline) return;
const [alice, bob, carol] = await Promise.all([signup(), signup(), signup()]);
@@ -1149,7 +1724,8 @@ describe('Timelines', () => {
});
test('withReplies: true でフォローしているユーザーの自分の visibility: followers な投稿への返信が含まれる', async () => {
- /* FIXME: https://github.com/misskey-dev/misskey/issues/12065 */ if (!enableFanoutTimeline) return;
+ /* FIXME: https://github.com/misskey-dev/misskey/issues/12065 */
+ if (!enableFanoutTimeline) return;
const [alice, bob] = await Promise.all([signup(), signup()]);
@@ -1225,7 +1801,8 @@ describe('Timelines', () => {
});
test('withReplies: false でフォローしていないユーザーからの自分への返信が含まれる', async () => {
- /* FIXME: https://github.com/misskey-dev/misskey/issues/12065 */ if (!enableFanoutTimeline) return;
+ /* FIXME: https://github.com/misskey-dev/misskey/issues/12065 */
+ if (!enableFanoutTimeline) return;
const [alice, bob] = await Promise.all([signup(), signup()]);
@@ -1269,6 +1846,280 @@ describe('Timelines', () => {
assert.strictEqual(res.body.some(note => note.id === bobNote2.id), true);
}, 1000 * 10);
+ describe('Channel', () => {
+ test('チャンネル未フォロー + ユーザ未フォロー = TLに流れない', async () => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
+
+ const channel = await createChannel('channel', bob);
+
+ const aliceNote = await post(alice, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
+
+ await waitForPushToTl();
+
+ const res = await api('notes/hybrid-timeline', { limit: 100 }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false);
+ });
+
+ test('チャンネルフォロー + ユーザ未フォロー = TLに流れる', async () => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
+
+ const channel = await createChannel('channel', bob);
+ await followChannel(channel.id, alice);
+
+ const aliceNote = await post(alice, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
+
+ await waitForPushToTl();
+
+ const res = await api('notes/hybrid-timeline', { limit: 100 }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), true);
+ });
+
+ test('チャンネル未フォロー + ユーザフォロー = TLに流れない', async () => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
+ await api('following/create', { userId: bob.id }, alice);
+
+ const channel = await createChannel('channel', bob);
+
+ const aliceNote = await post(alice, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
+
+ await waitForPushToTl();
+
+ const res = await api('notes/hybrid-timeline', { limit: 100 }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false);
+ });
+
+ test('チャンネルフォロー + ユーザフォロー = TLに流れる', async () => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
+ await api('following/create', { userId: bob.id }, alice);
+
+ const channel = await createChannel('channel', bob);
+ await followChannel(channel.id, alice);
+
+ const aliceNote = await post(alice, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
+
+ await waitForPushToTl();
+
+ const res = await api('notes/hybrid-timeline', { limit: 100 }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), true);
+ });
+
+ test('チャンネル未フォロー + ユーザ未フォロー + チャンネルミュート = TLに流れない', async () => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
+
+ const channel = await createChannel('channel', bob);
+ await muteChannel(channel.id, alice);
+
+ const aliceNote = await post(alice, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
+
+ await waitForPushToTl();
+
+ const res = await api('notes/hybrid-timeline', { limit: 100 }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false);
+ });
+
+ test('チャンネルフォロー + ユーザ未フォロー + チャンネルミュート = TLに流れない', async () => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
+
+ const channel = await createChannel('channel', bob);
+ await followChannel(channel.id, alice);
+ await muteChannel(channel.id, alice);
+
+ const aliceNote = await post(alice, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
+
+ await waitForPushToTl();
+
+ const res = await api('notes/hybrid-timeline', { limit: 100 }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false);
+ });
+
+ test('チャンネル未フォロー + ユーザフォロー + チャンネルミュート = TLに流れない', async () => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
+ await api('following/create', { userId: bob.id }, alice);
+
+ const channel = await createChannel('channel', bob);
+ await muteChannel(channel.id, alice);
+
+ const aliceNote = await post(alice, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
+
+ await waitForPushToTl();
+
+ const res = await api('notes/hybrid-timeline', { limit: 100 }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false);
+ });
+
+ test('チャンネルフォロー + ユーザフォロー + チャンネルミュート = TLに流れない', async () => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
+ await api('following/create', { userId: bob.id }, alice);
+
+ const channel = await createChannel('channel', bob);
+ await followChannel(channel.id, alice);
+ await muteChannel(channel.id, alice);
+
+ const aliceNote = await post(alice, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
+
+ await waitForPushToTl();
+
+ const res = await api('notes/hybrid-timeline', { limit: 100 }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false);
+ });
+
+ test('[チャンネル外リノート] チャンネル未フォロー + ユーザ未フォロー = TLに流れる', async () => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
+
+ const channel = await createChannel('channel', bob);
+
+ const aliceNote = await post(alice, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
+ const bobRenote = await renote(bobNote.id, bob);
+
+ await waitForPushToTl();
+
+ const res = await api('notes/hybrid-timeline', { limit: 100 }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === bobRenote.id), true);
+ });
+
+ test('[チャンネル外リノート] チャンネルフォロー + ユーザ未フォロー = TLに流れる', async () => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
+
+ const channel = await createChannel('channel', bob);
+ await followChannel(channel.id, alice);
+
+ const aliceNote = await post(alice, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
+ const bobRenote = await renote(bobNote.id, bob);
+
+ await waitForPushToTl();
+
+ const res = await api('notes/hybrid-timeline', { limit: 100 }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === bobRenote.id), true);
+ });
+
+ test('[チャンネル外リノート] チャンネル未フォロー + ユーザフォロー = TLに流れる', async () => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
+ await api('following/create', { userId: bob.id }, alice);
+
+ const channel = await createChannel('channel', bob);
+
+ const aliceNote = await post(alice, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
+ const bobRenote = await renote(bobNote.id, bob);
+
+ await waitForPushToTl();
+
+ const res = await api('notes/hybrid-timeline', { limit: 100 }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === bobRenote.id), true);
+ });
+
+ test('[チャンネル外リノート] チャンネルフォロー + ユーザフォロー = TLに流れる', async () => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
+ await api('following/create', { userId: bob.id }, alice);
+
+ const channel = await createChannel('channel', bob);
+ await followChannel(channel.id, alice);
+
+ const aliceNote = await post(alice, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
+ const bobRenote = await renote(bobNote.id, bob);
+
+ await waitForPushToTl();
+
+ const res = await api('notes/hybrid-timeline', { limit: 100 }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === bobRenote.id), true);
+ });
+
+ test('[チャンネル外リノート] チャンネル未フォロー + ユーザ未フォロー + チャンネルミュート = TLに流れない', async () => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
+
+ const channel = await createChannel('channel', bob);
+ await muteChannel(channel.id, alice);
+
+ const aliceNote = await post(alice, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
+ const bobRenote = await renote(bobNote.id, bob);
+
+ await waitForPushToTl();
+
+ const res = await api('notes/hybrid-timeline', { limit: 100 }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === bobRenote.id), false);
+ });
+
+ test('[チャンネル外リノート] チャンネルフォロー + ユーザ未フォロー + チャンネルミュート = TLに流れない', async () => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
+
+ const channel = await createChannel('channel', bob);
+ await followChannel(channel.id, alice);
+ await muteChannel(channel.id, alice);
+
+ const aliceNote = await post(alice, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
+ const bobRenote = await renote(bobNote.id, bob);
+
+ await waitForPushToTl();
+
+ const res = await api('notes/hybrid-timeline', { limit: 100 }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === bobRenote.id), false);
+ });
+
+ test('[チャンネル外リノート] チャンネル未フォロー + ユーザフォロー + チャンネルミュート = TLに流れない', async () => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
+ await api('following/create', { userId: bob.id }, alice);
+
+ const channel = await createChannel('channel', bob);
+ await muteChannel(channel.id, alice);
+
+ const aliceNote = await post(alice, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
+ const bobRenote = await renote(bobNote.id, bob);
+
+ await waitForPushToTl();
+
+ const res = await api('notes/hybrid-timeline', { limit: 100 }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === bobRenote.id), false);
+ });
+
+ test('[チャンネル外リノート] チャンネルフォロー + ユーザフォロー + チャンネルミュート = TLに流れない', async () => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
+ await api('following/create', { userId: bob.id }, alice);
+
+ const channel = await createChannel('channel', bob);
+ await followChannel(channel.id, alice);
+ await muteChannel(channel.id, alice);
+
+ const aliceNote = await post(alice, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
+ const bobRenote = await renote(bobNote.id, bob);
+
+ await waitForPushToTl();
+
+ const res = await api('notes/hybrid-timeline', { limit: 100 }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === bobRenote.id), false);
+ });
+ });
+
describe('凍結', () => {
/*
* bob = 未フォローのローカルユーザー (凍結対象でない)
@@ -1607,45 +2458,309 @@ describe('Timelines', () => {
assert.strictEqual(res.body.some(note => note.id === bobNote.id), false);
});
- describe('凍結', () => {
- let alice: SignupResponse, bob: SignupResponse, carol: SignupResponse;
- let aliceNote: Note, bobNote: Note, carolNote: Note;
- let list: UserList;
+ describe('Channel', () => {
+ test('チャンネル未フォロー + リスインしてない = TLに流れない', async () => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
- beforeAll(async () => {
- [alice, bob, carol] = await Promise.all([signup(), signup(), signup()]);
+ const list = await createList('list', alice);
- list = await api('users/lists/create', { name: 'list' }, alice).then(res => res.body);
+ const channel = await createChannel('channel', bob);
- await api('users/lists/push', { listId: list.id, userId: bob.id }, alice);
- await api('users/lists/push', { listId: list.id, userId: carol.id }, alice);
- aliceNote = await post(alice, { text: 'hi' });
- bobNote = await post(bob, { text: 'yo' });
- carolNote = await post(carol, { text: 'kon\'nichiwa' });
+ const aliceNote = await post(alice, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
await waitForPushToTl();
- await api('admin/suspend-user', { userId: carol.id }, root);
- await setTimeout(100);
+ const res = await api('notes/user-list-timeline', { limit: 100, listId: list.id }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false);
});
- test('凍結後に凍結されたユーザーのノートは見えなくなる', async () => {
- const res = await api('notes/user-list-timeline', { listId: list.id }, alice);
+ test('チャンネルフォロー + リスインしてない = TLに流れない', async () => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
- assert.strictEqual(res.body.some(note => note.id === aliceNote.id), false);
- assert.strictEqual(res.body.some(note => note.id === bobNote.id), true);
- assert.strictEqual(res.body.some(note => note.id === carolNote.id), false);
+ const list = await createList('list', alice);
+
+ const channel = await createChannel('channel', bob);
+ await followChannel(channel.id, alice);
+
+ const aliceNote = await post(alice, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
+
+ await waitForPushToTl();
+
+ const res = await api('notes/user-list-timeline', { limit: 100, listId: list.id }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false);
});
- test('凍結解除後に凍結されていたユーザーのノートは見えるようになる', async () => {
- await api('admin/unsuspend-user', { userId: carol.id }, root);
- await setTimeout(100);
+ test('チャンネル未フォロー + リスインしてる = TLに流れない', async () => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
- const res = await api('notes/user-list-timeline', { listId: list.id }, alice);
+ const list = await createList('list', alice);
+ await pushList(list.id, [bob.id], alice);
- assert.strictEqual(res.body.some(note => note.id === aliceNote.id), false);
- assert.strictEqual(res.body.some(note => note.id === bobNote.id), true);
- assert.strictEqual(res.body.some(note => note.id === carolNote.id), true);
+ const channel = await createChannel('channel', bob);
+
+ const aliceNote = await post(alice, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
+
+ await waitForPushToTl();
+
+ const res = await api('notes/user-list-timeline', { limit: 100, listId: list.id }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false);
+ });
+
+ test('チャンネルフォロー + リスインしてる = TLに流れない', async () => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
+
+ const list = await createList('list', alice);
+ await pushList(list.id, [bob.id], alice);
+
+ const channel = await createChannel('channel', bob);
+ await followChannel(channel.id, alice);
+
+ const aliceNote = await post(alice, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
+
+ await waitForPushToTl();
+
+ const res = await api('notes/user-list-timeline', { limit: 100, listId: list.id }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false);
+ });
+
+ test('チャンネル未フォロー + リスインしてない + チャンネルミュート = TLに流れない', async () => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
+
+ const list = await createList('list', alice);
+
+ const channel = await createChannel('channel', bob);
+ await muteChannel(channel.id, alice);
+
+ const aliceNote = await post(alice, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
+
+ await waitForPushToTl();
+
+ const res = await api('notes/user-list-timeline', { limit: 100, listId: list.id }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false);
+ });
+
+ test('チャンネルフォロー + リスインしてない + チャンネルミュート = TLに流れない', async () => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
+
+ const list = await createList('list', alice);
+
+ const channel = await createChannel('channel', bob);
+ await followChannel(channel.id, alice);
+ await muteChannel(channel.id, alice);
+
+ const aliceNote = await post(alice, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
+
+ await waitForPushToTl();
+
+ const res = await api('notes/user-list-timeline', { limit: 100, listId: list.id }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false);
+ });
+
+ test('チャンネル未フォロー + リスインしてる + チャンネルミュート = TLに流れない', async () => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
+
+ const list = await createList('list', alice);
+ await pushList(list.id, [bob.id], alice);
+
+ const channel = await createChannel('channel', bob);
+ await muteChannel(channel.id, alice);
+
+ const aliceNote = await post(alice, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
+
+ await waitForPushToTl();
+
+ const res = await api('notes/user-list-timeline', { limit: 100, listId: list.id }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false);
+ });
+
+ test('チャンネルフォロー + リスインしてる + チャンネルミュート = TLに流れない', async () => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
+
+ const list = await createList('list', alice);
+ await pushList(list.id, [bob.id], alice);
+
+ const channel = await createChannel('channel', bob);
+ await followChannel(channel.id, alice);
+ await muteChannel(channel.id, alice);
+
+ const aliceNote = await post(alice, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
+
+ await waitForPushToTl();
+
+ const res = await api('notes/user-list-timeline', { limit: 100, listId: list.id }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false);
+ });
+
+ test('[チャンネル外リノート] チャンネル未フォロー + リスインしてない = TLに流れない', async () => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
+
+ const list = await createList('list', alice);
+
+ const channel = await createChannel('channel', bob);
+
+ const aliceNote = await post(alice, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
+ const bobRenote = await renote(bobNote.id, bob);
+
+ await waitForPushToTl();
+
+ const res = await api('notes/user-list-timeline', { limit: 100, listId: list.id }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === bobRenote.id), false);
+ });
+
+ test('[チャンネル外リノート] チャンネルフォロー + リスインしてない = TLに流れない', async () => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
+
+ const list = await createList('list', alice);
+
+ const channel = await createChannel('channel', bob);
+ await followChannel(channel.id, alice);
+
+ const aliceNote = await post(alice, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
+ const bobRenote = await renote(bobNote.id, bob);
+
+ await waitForPushToTl();
+
+ const res = await api('notes/user-list-timeline', { limit: 100, listId: list.id }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === bobRenote.id), false);
+ });
+
+ test('[チャンネル外リノート] チャンネル未フォロー + リスインしてる = TLに流れる', async () => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
+
+ const list = await createList('list', alice);
+ await pushList(list.id, [bob.id], alice);
+
+ const channel = await createChannel('channel', bob);
+
+ const aliceNote = await post(alice, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
+ const bobRenote = await renote(bobNote.id, bob);
+
+ await waitForPushToTl();
+
+ const res = await api('notes/user-list-timeline', { limit: 100, listId: list.id }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === bobRenote.id), true);
+ });
+
+ test('[チャンネル外リノート] チャンネルフォロー + リスインしてる = TLに流れる', async () => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
+
+ const list = await createList('list', alice);
+ await pushList(list.id, [bob.id], alice);
+
+ const channel = await createChannel('channel', bob);
+ await followChannel(channel.id, alice);
+
+ const aliceNote = await post(alice, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
+ const bobRenote = await renote(bobNote.id, bob);
+
+ await waitForPushToTl();
+
+ const res = await api('notes/user-list-timeline', { limit: 100, listId: list.id }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === bobRenote.id), true);
+ });
+
+ test('[チャンネル外リノート] チャンネル未フォロー + リスインしてない + チャンネルミュート = TLに流れない', async () => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
+
+ const list = await createList('list', alice);
+
+ const channel = await createChannel('channel', bob);
+ await muteChannel(channel.id, alice);
+
+ const aliceNote = await post(alice, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
+ const bobRenote = await renote(bobNote.id, bob);
+
+ await waitForPushToTl();
+
+ const res = await api('notes/user-list-timeline', { limit: 100, listId: list.id }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === bobRenote.id), false);
+ });
+
+ test('[チャンネル外リノート] チャンネルフォロー + リスインしてない + チャンネルミュート = TLに流れない', async () => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
+
+ const list = await createList('list', alice);
+
+ const channel = await createChannel('channel', bob);
+ await followChannel(channel.id, alice);
+ await muteChannel(channel.id, alice);
+
+ const aliceNote = await post(alice, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
+ const bobRenote = await renote(bobNote.id, bob);
+
+ await waitForPushToTl();
+
+ const res = await api('notes/user-list-timeline', { limit: 100, listId: list.id }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === bobRenote.id), false);
+ });
+
+ test('[チャンネル外リノート] チャンネル未フォロー + リスインしてる + チャンネルミュート = TLに流れない', async () => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
+
+ const list = await createList('list', alice);
+ await pushList(list.id, [bob.id], alice);
+
+ const channel = await createChannel('channel', bob);
+ await muteChannel(channel.id, alice);
+
+ const aliceNote = await post(alice, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
+ const bobRenote = await renote(bobNote.id, bob);
+
+ await waitForPushToTl();
+
+ const res = await api('notes/user-list-timeline', { limit: 100, listId: list.id }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === bobRenote.id), false);
+ });
+
+ test('[チャンネル外リノート] チャンネルフォロー + リスインしてる + チャンネルミュート = TLに流れない', async () => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
+
+ const list = await createList('list', alice);
+ await pushList(list.id, [bob.id], alice);
+
+ const channel = await createChannel('channel', bob);
+ await followChannel(channel.id, alice);
+ await muteChannel(channel.id, alice);
+
+ const aliceNote = await post(alice, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
+ const bobRenote = await renote(bobNote.id, bob);
+
+ await waitForPushToTl();
+
+ const res = await api('notes/user-list-timeline', { limit: 100, listId: list.id }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === bobRenote.id), false);
});
});
});
@@ -1937,8 +3052,276 @@ describe('Timelines', () => {
const res = await api('users/notes', { userId: alice.id, sinceId: noteSince.id, untilId: noteUntil.id });
assert.deepStrictEqual(res.body, [note3, note2, note1]);
});
+
+ describe('Channel', () => {
+ test('チャンネルミュートなし = TLに流れる', async () => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
+
+ const channel = await createChannel('channel', bob);
+
+ const aliceNote = await post(alice, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
+
+ await waitForPushToTl();
+
+ const res = await api('users/notes', { userId: bob.id, withChannelNotes: true }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), true);
+ });
+
+ test('チャンネルミュート = TLに流れない', async () => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
+
+ const channel = await createChannel('channel', bob);
+ await muteChannel(channel.id, alice);
+
+ const aliceNote = await post(alice, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
+
+ await waitForPushToTl();
+
+ const res = await api('users/notes', { userId: bob.id, withChannelNotes: true }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false);
+ });
+
+ test('[チャンネル外リノート] チャンネルミュートなし = TLに流れる', async () => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
+
+ const channel = await createChannel('channel', bob);
+
+ const aliceNote = await post(alice, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
+ const bobRenote = await renote(bobNote.id, bob);
+
+ await waitForPushToTl();
+
+ const res = await api('users/notes', { userId: bob.id, withChannelNotes: true }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === bobRenote.id), true);
+ });
+
+ test('[チャンネル外リノート] チャンネルミュート = TLに流れない', async () => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
+
+ const channel = await createChannel('channel', bob);
+ await muteChannel(channel.id, alice);
+
+ const aliceNote = await post(alice, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
+ const bobRenote = await renote(bobNote.id, bob);
+
+ await waitForPushToTl();
+
+ const res = await api('users/notes', { userId: bob.id, withChannelNotes: true }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === bobRenote.id), false);
+ });
+ });
});
+ describe('Channel TL', () => {
+ test('閲覧中チャンネルのノートが含まれる', async () => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
+
+ const channel = await createChannel('channel', bob);
+
+ const aliceNote = await post(alice, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
+
+ await waitForPushToTl();
+
+ const res = await api('channels/timeline', { channelId: channel.id }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === aliceNote.id), false);
+ assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), true);
+ });
+
+ test('閲覧中チャンネルとは別チャンネルのノートは含まれない', async() => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
+
+ const channel = await createChannel('channel', bob);
+ const channel2 = await createChannel('channel', bob);
+
+ const aliceNote = await post(alice, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'ok', channelId: channel2.id });
+
+ await waitForPushToTl();
+
+ const res = await api('channels/timeline', { channelId: channel.id }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === aliceNote.id), false);
+ assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false);
+ });
+
+ test('閲覧中チャンネルのノートにリノートが含まれる', async() => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
+
+ const channel = await createChannel('channel', bob);
+
+ const aliceNote = await post(alice, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
+ const bobRenote = await post(bob, { channelId: channel.id, renoteId: bobNote.id });
+
+ await waitForPushToTl();
+
+ const res = await api('channels/timeline', { channelId: channel.id }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === bobRenote.id), true);
+ });
+
+ test('閲覧中チャンネルとは別チャンネルからのリノートが含まれる', async() => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
+
+ const channel = await createChannel('channel', bob);
+ const channel2 = await createChannel('channel', bob);
+
+ const aliceNote = await post(alice, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'ok', channelId: channel2.id });
+ const bobRenote = await post(bob, { channelId: channel.id, renoteId: bobNote.id });
+
+ await waitForPushToTl();
+
+ const res = await api('channels/timeline', { channelId: channel.id }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === bobRenote.id), true);
+ });
+
+ test('閲覧中チャンネルに自分の他人への返信が含まれる', async () => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
+
+ const channel = await createChannel('channel', bob);
+
+ const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
+ const aliceNote = await post(alice, { text: 'hi', replyId: bobNote.id, channelId: channel.id });
+
+ await waitForPushToTl();
+
+ const res = await api('channels/timeline', { channelId: channel.id }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === aliceNote.id), true);
+ });
+
+ test('閲覧中チャンネルに他人の自分への返信が含まれる', async () => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
+
+ const channel = await createChannel('channel', bob);
+
+ const aliceNote = await post(alice, { text: 'hi', channelId: channel.id });
+ const bobNote = await post(bob, { text: 'ok', replyId: aliceNote.id, channelId: channel.id });
+
+ await waitForPushToTl();
+
+ const res = await api('channels/timeline', { channelId: channel.id }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), true);
+ });
+
+ test('閲覧中チャンネルにミュートしているユーザのノートは含まれない', async () => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
+
+ await api('mute/create', { userId: bob.id }, alice);
+
+ const channel = await createChannel('channel', bob);
+
+ const aliceNote = await post(alice, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
+
+ await waitForPushToTl();
+
+ const res = await api('channels/timeline', { channelId: channel.id }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === aliceNote.id), false);
+ assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false);
+ });
+
+ test('閲覧中チャンネルにこちらをブロックしているユーザのノートは含まれない', async () => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
+
+ await api('blocking/create', { userId: alice.id }, bob);
+
+ const channel = await createChannel('channel', bob);
+
+ const aliceNote = await post(alice, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
+
+ await waitForPushToTl();
+
+ const res = await api('channels/timeline', { channelId: channel.id }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === aliceNote.id), false);
+ assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false);
+ });
+
+ test('閲覧中チャンネルをミュートしていてもノートが含まれる', async () => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
+
+ const channel = await createChannel('channel', bob);
+ await muteChannel(channel.id, alice);
+
+ const aliceNote = await post(alice, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
+
+ await waitForPushToTl();
+
+ const res = await api('channels/timeline', { channelId: channel.id }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === aliceNote.id), false);
+ assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), true);
+ });
+
+ test('閲覧中チャンネルをミュートしていても、同チャンネルのリノートが含まれる', async () => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
+
+ const channel = await createChannel('channel', bob);
+ await muteChannel(channel.id, alice);
+
+ const aliceNote = await post(alice, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
+ const bobRenote = await post(bob, { channelId: channel.id, renoteId: bobNote.id });
+
+ await waitForPushToTl();
+
+ const res = await api('channels/timeline', { channelId: channel.id }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === bobRenote.id), true);
+ });
+
+ test('閲覧中チャンネルをミュートしていても、同チャンネルのリプライが含まれる', async () => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
+
+ const channel = await createChannel('channel', bob);
+ await muteChannel(channel.id, alice);
+
+ const aliceNote = await post(alice, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'ok', channelId: channel.id });
+ const bobRenote = await post(bob, { channelId: channel.id, replyId: bobNote.id, text: 'ho' });
+
+ await waitForPushToTl();
+
+ const res = await api('channels/timeline', { channelId: channel.id }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === bobRenote.id), true);
+ });
+
+ test('閲覧中チャンネルとは別チャンネルをミュートしているとき、そのチャンネルからのリノートは含まれない', async() => {
+ const [alice, bob] = await Promise.all([signup(), signup()]);
+
+ const channel = await createChannel('channel', bob);
+ const channel2 = await createChannel('channel', bob);
+ await muteChannel(channel2.id, alice);
+
+ const aliceNote = await post(alice, { text: 'hi' });
+ const bobNote = await post(bob, { text: 'ok', channelId: channel2.id });
+ const bobRenote = await post(bob, { channelId: channel.id, renoteId: bobNote.id });
+
+ await waitForPushToTl();
+
+ const res = await api('channels/timeline', { channelId: channel.id }, alice);
+
+ assert.strictEqual(res.body.some((note: any) => note.id === bobRenote.id), false);
+ });
+ });
// TODO: リノートミュート済みユーザーのテスト
// TODO: ページネーションのテスト
});
diff --git a/packages/backend/test/jest.setup.unit.cjs b/packages/backend/test/jest.setup.unit.cjs
new file mode 100644
index 0000000000..dd879c81c8
--- /dev/null
+++ b/packages/backend/test/jest.setup.unit.cjs
@@ -0,0 +1,10 @@
+/*
+ * SPDX-FileCopyrightText: syuilo and misskey-project
+ * SPDX-License-Identifier: AGPL-3.0-only
+ */
+
+module.exports = async () => {
+ // DBはUTC(っぽい)ので、テスト側も合わせておく
+ process.env.TZ = 'UTC';
+ process.env.NODE_ENV = 'test';
+};
diff --git a/packages/backend/test/unit/ChannelFollowingService.ts b/packages/backend/test/unit/ChannelFollowingService.ts
new file mode 100644
index 0000000000..2d3196f2f4
--- /dev/null
+++ b/packages/backend/test/unit/ChannelFollowingService.ts
@@ -0,0 +1,235 @@
+/*
+ * SPDX-FileCopyrightText: syuilo and misskey-project
+ * SPDX-License-Identifier: AGPL-3.0-only
+ */
+
+/* eslint-disable */
+
+import { afterEach, beforeEach, describe, expect } from '@jest/globals';
+import { Test, TestingModule } from '@nestjs/testing';
+import { GlobalModule } from '@/GlobalModule.js';
+import { CoreModule } from '@/core/CoreModule.js';
+import { GlobalEventService } from '@/core/GlobalEventService.js';
+import { IdService } from '@/core/IdService.js';
+import {
+ type ChannelFollowingsRepository,
+ ChannelsRepository,
+ DriveFilesRepository,
+ MiChannel,
+ MiChannelFollowing,
+ MiDriveFile,
+ MiUser,
+ UserProfilesRepository,
+ UsersRepository,
+} from '@/models/_.js';
+import { DI } from '@/di-symbols.js';
+import { ChannelFollowingService } from "@/core/ChannelFollowingService.js";
+import { MiLocalUser } from "@/models/User.js";
+
+describe('ChannelFollowingService', () => {
+ let app: TestingModule;
+ let service: ChannelFollowingService;
+ let channelsRepository: ChannelsRepository;
+ let channelFollowingsRepository: ChannelFollowingsRepository;
+ let usersRepository: UsersRepository;
+ let userProfilesRepository: UserProfilesRepository;
+ let driveFilesRepository: DriveFilesRepository;
+ let idService: IdService;
+
+ let alice: MiLocalUser;
+ let bob: MiLocalUser;
+ let channel1: MiChannel;
+ let channel2: MiChannel;
+ let channel3: MiChannel;
+ let driveFile1: MiDriveFile;
+ let driveFile2: MiDriveFile;
+
+ async function createUser(data: Partial<MiUser> = {}) {
+ const user = await usersRepository
+ .insert({
+ id: idService.gen(),
+ username: 'username',
+ usernameLower: 'username',
+ ...data,
+ })
+ .then(x => usersRepository.findOneByOrFail(x.identifiers[0]));
+
+ await userProfilesRepository.insert({
+ userId: user.id,
+ });
+
+ return user;
+ }
+
+ async function createChannel(data: Partial<MiChannel> = {}) {
+ return await channelsRepository
+ .insert({
+ id: idService.gen(),
+ ...data,
+ })
+ .then(x => channelsRepository.findOneByOrFail(x.identifiers[0]));
+ }
+
+ async function createChannelFollowing(data: Partial<MiChannelFollowing> = {}) {
+ return await channelFollowingsRepository
+ .insert({
+ id: idService.gen(),
+ ...data,
+ })
+ .then(x => channelFollowingsRepository.findOneByOrFail(x.identifiers[0]));
+ }
+
+ async function fetchChannelFollowing() {
+ return await channelFollowingsRepository.findBy({});
+ }
+
+ async function createDriveFile(data: Partial<MiDriveFile> = {}) {
+ return await driveFilesRepository
+ .insert({
+ id: idService.gen(),
+ md5: 'md5',
+ name: 'name',
+ size: 0,
+ type: 'type',
+ storedInternal: false,
+ url: 'url',
+ ...data,
+ })
+ .then(x => driveFilesRepository.findOneByOrFail(x.identifiers[0]));
+ }
+
+ beforeAll(async () => {
+ app = await Test.createTestingModule({
+ imports: [
+ GlobalModule,
+ CoreModule,
+ ],
+ providers: [
+ GlobalEventService,
+ IdService,
+ ChannelFollowingService,
+ ],
+ }).compile();
+
+ app.enableShutdownHooks();
+
+ service = app.get<ChannelFollowingService>(ChannelFollowingService);
+ idService = app.get<IdService>(IdService);
+ channelsRepository = app.get<ChannelsRepository>(DI.channelsRepository);
+ channelFollowingsRepository = app.get<ChannelFollowingsRepository>(DI.channelFollowingsRepository);
+ usersRepository = app.get<UsersRepository>(DI.usersRepository);
+ userProfilesRepository = app.get<UserProfilesRepository>(DI.userProfilesRepository);
+ driveFilesRepository = app.get<DriveFilesRepository>(DI.driveFilesRepository);
+ });
+
+ afterAll(async () => {
+ await app.close();
+ });
+
+ beforeEach(async () => {
+ alice = { ...await createUser({ username: 'alice' }), host: null, uri: null };
+ bob = { ...await createUser({ username: 'bob' }), host: null, uri: null };
+ driveFile1 = await createDriveFile();
+ driveFile2 = await createDriveFile();
+ channel1 = await createChannel({ name: 'channel1', userId: alice.id, bannerId: driveFile1.id });
+ channel2 = await createChannel({ name: 'channel2', userId: alice.id, bannerId: driveFile2.id });
+ channel3 = await createChannel({ name: 'channel3', userId: alice.id, bannerId: driveFile2.id });
+ });
+
+ afterEach(async () => {
+ await channelFollowingsRepository.deleteAll();
+ await channelsRepository.deleteAll();
+ await userProfilesRepository.deleteAll();
+ await usersRepository.deleteAll();
+ });
+
+ describe('list', () => {
+ test('default', async () => {
+ await createChannelFollowing({ followerId: alice.id, followeeId: channel1.id });
+ await createChannelFollowing({ followerId: alice.id, followeeId: channel2.id });
+ await createChannelFollowing({ followerId: bob.id, followeeId: channel3.id });
+
+ const followings = await service.list({ requestUserId: alice.id });
+
+ expect(followings).toHaveLength(2);
+ expect(followings[0].id).toBe(channel1.id);
+ expect(followings[0].userId).toBe(alice.id);
+ expect(followings[0].user).toBeFalsy();
+ expect(followings[0].bannerId).toBe(driveFile1.id);
+ expect(followings[0].banner).toBeFalsy();
+ expect(followings[1].id).toBe(channel2.id);
+ expect(followings[1].userId).toBe(alice.id);
+ expect(followings[1].user).toBeFalsy();
+ expect(followings[1].bannerId).toBe(driveFile2.id);
+ expect(followings[1].banner).toBeFalsy();
+ });
+
+ test('idOnly', async () => {
+ await createChannelFollowing({ followerId: alice.id, followeeId: channel1.id });
+ await createChannelFollowing({ followerId: alice.id, followeeId: channel2.id });
+ await createChannelFollowing({ followerId: bob.id, followeeId: channel3.id });
+
+ const followings = await service.list({ requestUserId: alice.id }, { idOnly: true });
+
+ expect(followings).toHaveLength(2);
+ expect(followings[0].id).toBe(channel1.id);
+ expect(followings[1].id).toBe(channel2.id);
+ });
+
+ test('joinUser', async () => {
+ await createChannelFollowing({ followerId: alice.id, followeeId: channel1.id });
+ await createChannelFollowing({ followerId: alice.id, followeeId: channel2.id });
+ await createChannelFollowing({ followerId: bob.id, followeeId: channel3.id });
+
+ const followings = await service.list({ requestUserId: alice.id }, { joinUser: true });
+
+ expect(followings).toHaveLength(2);
+ expect(followings[0].id).toBe(channel1.id);
+ expect(followings[0].user).toEqual(alice);
+ expect(followings[0].banner).toBeFalsy();
+ expect(followings[1].id).toBe(channel2.id);
+ expect(followings[1].user).toEqual(alice);
+ expect(followings[1].banner).toBeFalsy();
+ });
+
+ test('joinBannerFile', async () => {
+ await createChannelFollowing({ followerId: alice.id, followeeId: channel1.id });
+ await createChannelFollowing({ followerId: alice.id, followeeId: channel2.id });
+ await createChannelFollowing({ followerId: bob.id, followeeId: channel3.id });
+
+ const followings = await service.list({ requestUserId: alice.id }, { joinBannerFile: true });
+
+ expect(followings).toHaveLength(2);
+ expect(followings[0].id).toBe(channel1.id);
+ expect(followings[0].user).toBeFalsy();
+ expect(followings[0].banner).toEqual(driveFile1);
+ expect(followings[1].id).toBe(channel2.id);
+ expect(followings[1].user).toBeFalsy();
+ expect(followings[1].banner).toEqual(driveFile2);
+ });
+ });
+
+ describe('follow', () => {
+ test('default', async () => {
+ await service.follow(alice, channel1);
+
+ const followings = await fetchChannelFollowing();
+
+ expect(followings).toHaveLength(1);
+ expect(followings[0].followeeId).toBe(channel1.id);
+ expect(followings[0].followerId).toBe(alice.id);
+ });
+ });
+
+ describe('unfollow', () => {
+ test('default', async () => {
+ await createChannelFollowing({ followerId: alice.id, followeeId: channel1.id });
+
+ await service.unfollow(alice, channel1);
+
+ const followings = await fetchChannelFollowing();
+
+ expect(followings).toHaveLength(0);
+ });
+ });
+});
diff --git a/packages/backend/test/unit/ChannelMutingService.ts b/packages/backend/test/unit/ChannelMutingService.ts
new file mode 100644
index 0000000000..6916701d1f
--- /dev/null
+++ b/packages/backend/test/unit/ChannelMutingService.ts
@@ -0,0 +1,336 @@
+/*
+ * SPDX-FileCopyrightText: syuilo and misskey-project
+ * SPDX-License-Identifier: AGPL-3.0-only
+ */
+
+/* eslint-disable */
+
+import { afterEach, beforeEach, describe, expect } from '@jest/globals';
+import { Test, TestingModule } from '@nestjs/testing';
+import { GlobalModule } from '@/GlobalModule.js';
+import { CoreModule } from '@/core/CoreModule.js';
+import { GlobalEventService } from '@/core/GlobalEventService.js';
+import { IdService } from '@/core/IdService.js';
+import { ChannelMutingService } from '@/core/ChannelMutingService.js';
+import {
+ ChannelMutingRepository,
+ ChannelsRepository,
+ DriveFilesRepository,
+ MiChannel,
+ MiChannelMuting,
+ MiDriveFile,
+ MiUser,
+ UserProfilesRepository,
+ UsersRepository,
+} from '@/models/_.js';
+import { DI } from '@/di-symbols.js';
+import { setTimeout } from 'node:timers/promises';
+
+describe('ChannelMutingService', () => {
+ let app: TestingModule;
+ let service: ChannelMutingService;
+ let channelsRepository: ChannelsRepository;
+ let channelMutingRepository: ChannelMutingRepository;
+ let usersRepository: UsersRepository;
+ let userProfilesRepository: UserProfilesRepository;
+ let driveFilesRepository: DriveFilesRepository;
+ let idService: IdService;
+
+ let alice: MiUser;
+ let bob: MiUser;
+ let channel1: MiChannel;
+ let channel2: MiChannel;
+ let channel3: MiChannel;
+ let driveFile1: MiDriveFile;
+ let driveFile2: MiDriveFile;
+
+ async function createUser(data: Partial<MiUser> = {}) {
+ const user = await usersRepository
+ .insert({
+ id: idService.gen(),
+ username: 'username',
+ usernameLower: 'username',
+ ...data,
+ })
+ .then(x => usersRepository.findOneByOrFail(x.identifiers[0]));
+
+ await userProfilesRepository.insert({
+ userId: user.id,
+ });
+
+ return user;
+ }
+
+ async function createChannel(data: Partial<MiChannel> = {}) {
+ return await channelsRepository
+ .insert({
+ id: idService.gen(),
+ ...data,
+ })
+ .then(x => channelsRepository.findOneByOrFail(x.identifiers[0]));
+ }
+
+ async function createChannelMuting(data: Partial<MiChannelMuting> = {}) {
+ return await channelMutingRepository
+ .insert({
+ id: idService.gen(),
+ ...data,
+ })
+ .then(x => channelMutingRepository.findOneByOrFail(x.identifiers[0]));
+ }
+
+ async function fetchChannelMuting() {
+ return await channelMutingRepository.findBy({});
+ }
+
+ async function createDriveFile(data: Partial<MiDriveFile> = {}) {
+ return await driveFilesRepository
+ .insert({
+ id: idService.gen(),
+ md5: 'md5',
+ name: 'name',
+ size: 0,
+ type: 'type',
+ storedInternal: false,
+ url: 'url',
+ ...data,
+ })
+ .then(x => driveFilesRepository.findOneByOrFail(x.identifiers[0]));
+ }
+
+ beforeAll(async () => {
+ app = await Test.createTestingModule({
+ imports: [
+ GlobalModule,
+ CoreModule,
+ ],
+ providers: [
+ GlobalEventService,
+ IdService,
+ ChannelMutingService,
+ ],
+ }).compile();
+
+ app.enableShutdownHooks();
+
+ service = app.get<ChannelMutingService>(ChannelMutingService);
+ idService = app.get<IdService>(IdService);
+ channelsRepository = app.get<ChannelsRepository>(DI.channelsRepository);
+ channelMutingRepository = app.get<ChannelMutingRepository>(DI.channelMutingRepository);
+ usersRepository = app.get<UsersRepository>(DI.usersRepository);
+ userProfilesRepository = app.get<UserProfilesRepository>(DI.userProfilesRepository);
+ driveFilesRepository = app.get<DriveFilesRepository>(DI.driveFilesRepository);
+ });
+
+ afterAll(async () => {
+ await app.close();
+ });
+
+ beforeEach(async () => {
+ alice = await createUser({ username: 'alice' });
+ bob = await createUser({ username: 'bob' });
+ driveFile1 = await createDriveFile();
+ driveFile2 = await createDriveFile();
+ channel1 = await createChannel({ name: 'channel1', userId: alice.id, bannerId: driveFile1.id });
+ channel2 = await createChannel({ name: 'channel2', userId: alice.id, bannerId: driveFile2.id });
+ channel3 = await createChannel({ name: 'channel3', userId: alice.id, bannerId: driveFile2.id });
+ });
+
+ afterEach(async () => {
+ await channelMutingRepository.deleteAll();
+ await channelsRepository.deleteAll();
+ await userProfilesRepository.deleteAll();
+ await usersRepository.deleteAll();
+ });
+
+ describe('list', () => {
+ test('default', async () => {
+ await createChannelMuting({ userId: alice.id, channelId: channel1.id });
+ await createChannelMuting({ userId: alice.id, channelId: channel2.id });
+ await createChannelMuting({ userId: bob.id, channelId: channel3.id });
+
+ const mutings = await service.list({ requestUserId: alice.id });
+
+ expect(mutings).toHaveLength(2);
+ expect(mutings[0].id).toBe(channel1.id);
+ expect(mutings[0].userId).toBe(alice.id);
+ expect(mutings[0].user).toBeFalsy();
+ expect(mutings[0].bannerId).toBe(driveFile1.id);
+ expect(mutings[0].banner).toBeFalsy();
+ expect(mutings[1].id).toBe(channel2.id);
+ expect(mutings[1].userId).toBe(alice.id);
+ expect(mutings[1].user).toBeFalsy();
+ expect(mutings[1].bannerId).toBe(driveFile2.id);
+ expect(mutings[1].banner).toBeFalsy();
+ });
+
+ test('withoutExpires', async () => {
+ const now = new Date();
+ const past = new Date(now);
+ const future = new Date(now);
+ past.setMinutes(past.getMinutes() - 1);
+ future.setMinutes(future.getMinutes() + 1);
+
+ await createChannelMuting({ userId: alice.id, channelId: channel1.id, expiresAt: past });
+ await createChannelMuting({ userId: alice.id, channelId: channel2.id, expiresAt: null });
+ await createChannelMuting({ userId: alice.id, channelId: channel3.id, expiresAt: future });
+
+ const mutings = await service.list({ requestUserId: alice.id });
+
+ expect(mutings).toHaveLength(2);
+ expect(mutings[0].id).toBe(channel2.id);
+ expect(mutings[1].id).toBe(channel3.id);
+ });
+
+ test('idOnly', async () => {
+ await createChannelMuting({ userId: alice.id, channelId: channel1.id });
+ await createChannelMuting({ userId: alice.id, channelId: channel2.id });
+ await createChannelMuting({ userId: bob.id, channelId: channel3.id });
+
+ const mutings = await service.list({ requestUserId: alice.id }, { idOnly: true });
+
+ expect(mutings).toHaveLength(2);
+ expect(mutings[0].id).toBe(channel1.id);
+ expect(mutings[1].id).toBe(channel2.id);
+ });
+
+ test('withoutExpires-idOnly', async () => {
+ const now = new Date();
+ const past = new Date(now);
+ const future = new Date(now);
+ past.setMinutes(past.getMinutes() - 1);
+ future.setMinutes(future.getMinutes() + 1);
+
+ await createChannelMuting({ userId: alice.id, channelId: channel1.id, expiresAt: past });
+ await createChannelMuting({ userId: alice.id, channelId: channel2.id, expiresAt: null });
+ await createChannelMuting({ userId: alice.id, channelId: channel3.id, expiresAt: future });
+
+ const mutings = await service.list({ requestUserId: alice.id }, { idOnly: true });
+
+ expect(mutings).toHaveLength(2);
+ expect(mutings[0].id).toBe(channel2.id);
+ expect(mutings[1].id).toBe(channel3.id);
+ });
+
+ test('joinUser', async () => {
+ await createChannelMuting({ userId: alice.id, channelId: channel1.id });
+ await createChannelMuting({ userId: alice.id, channelId: channel2.id });
+ await createChannelMuting({ userId: bob.id, channelId: channel3.id });
+
+ const mutings = await service.list({ requestUserId: alice.id }, { joinUser: true });
+
+ expect(mutings).toHaveLength(2);
+ expect(mutings[0].id).toBe(channel1.id);
+ expect(mutings[0].user).toEqual(alice);
+ expect(mutings[0].banner).toBeFalsy();
+ expect(mutings[1].id).toBe(channel2.id);
+ expect(mutings[1].user).toEqual(alice);
+ expect(mutings[1].banner).toBeFalsy();
+ });
+
+ test('joinBannerFile', async () => {
+ await createChannelMuting({ userId: alice.id, channelId: channel1.id });
+ await createChannelMuting({ userId: alice.id, channelId: channel2.id });
+ await createChannelMuting({ userId: bob.id, channelId: channel3.id });
+
+ const mutings = await service.list({ requestUserId: alice.id }, { joinBannerFile: true });
+
+ expect(mutings).toHaveLength(2);
+ expect(mutings[0].id).toBe(channel1.id);
+ expect(mutings[0].user).toBeFalsy();
+ expect(mutings[0].banner).toEqual(driveFile1);
+ expect(mutings[1].id).toBe(channel2.id);
+ expect(mutings[1].user).toBeFalsy();
+ expect(mutings[1].banner).toEqual(driveFile2);
+ });
+ });
+
+ describe('findExpiredMutings', () => {
+ test('default', async () => {
+ const now = new Date();
+ const future = new Date(now);
+ const past = new Date(now);
+ future.setMinutes(now.getMinutes() + 1);
+ past.setMinutes(now.getMinutes() - 1);
+
+ await createChannelMuting({ userId: alice.id, channelId: channel1.id, expiresAt: past });
+ await createChannelMuting({ userId: alice.id, channelId: channel2.id, expiresAt: future });
+ await createChannelMuting({ userId: bob.id, channelId: channel3.id, expiresAt: past });
+
+ const mutings = await service.findExpiredMutings();
+
+ expect(mutings).toHaveLength(2);
+ expect(mutings[0].channelId).toBe(channel1.id);
+ expect(mutings[1].channelId).toBe(channel3.id);
+ });
+ });
+
+ describe('isMuted', () => {
+ test('isMuted: true', async () => {
+ // キャッシュを読むのでServiceの機能を使って登録し、キャッシュを作成する
+ await service.mute({ requestUserId: alice.id, targetChannelId: channel1.id });
+ await service.mute({ requestUserId: alice.id, targetChannelId: channel2.id });
+
+ await setTimeout(500);
+
+ const result = await service.isMuted({ requestUserId: alice.id, targetChannelId: channel1.id });
+
+ expect(result).toBe(true);
+ });
+
+ test('isMuted: false', async () => {
+ await service.mute({ requestUserId: alice.id, targetChannelId: channel2.id });
+
+ await setTimeout(500);
+
+ const result = await service.isMuted({ requestUserId: alice.id, targetChannelId: channel1.id });
+
+ expect(result).toBe(false);
+ });
+ });
+
+ describe('mute', () => {
+ test('default', async () => {
+ await service.mute({ requestUserId: alice.id, targetChannelId: channel1.id });
+
+ const muting = await fetchChannelMuting();
+ expect(muting).toHaveLength(1);
+ expect(muting[0].channelId).toBe(channel1.id);
+ });
+ });
+
+ describe('unmute', () => {
+ test('default', async () => {
+ await createChannelMuting({ userId: alice.id, channelId: channel1.id });
+
+ let muting = await fetchChannelMuting();
+ expect(muting).toHaveLength(1);
+ expect(muting[0].channelId).toBe(channel1.id);
+
+ await service.unmute({ requestUserId: alice.id, targetChannelId: channel1.id });
+
+ muting = await fetchChannelMuting();
+ expect(muting).toHaveLength(0);
+ });
+ });
+
+ describe('eraseExpiredMutings', () => {
+ test('default', async () => {
+ const now = new Date();
+ const future = new Date(now);
+ const past = new Date(now);
+ future.setMinutes(now.getMinutes() + 1);
+ past.setMinutes(now.getMinutes() - 1);
+
+ await createChannelMuting({ userId: alice.id, channelId: channel1.id, expiresAt: past });
+ await createChannelMuting({ userId: alice.id, channelId: channel2.id, expiresAt: future });
+ await createChannelMuting({ userId: bob.id, channelId: channel3.id, expiresAt: past });
+
+ await service.eraseExpiredMutings();
+
+ const mutings = await fetchChannelMuting();
+ expect(mutings).toHaveLength(1);
+ expect(mutings[0].channelId).toBe(channel2.id);
+ });
+ });
+});
diff --git a/packages/backend/test/unit/NoteCreateService.ts b/packages/backend/test/unit/NoteCreateService.ts
index 23f409420e..f3d3d1da99 100644
--- a/packages/backend/test/unit/NoteCreateService.ts
+++ b/packages/backend/test/unit/NoteCreateService.ts
@@ -61,6 +61,7 @@ describe('NoteCreateService', () => {
replyUserHost: null,
renoteUserId: null,
renoteUserHost: null,
+ renoteChannelId: null,
};
const poll: IPoll = {
diff --git a/packages/backend/test/unit/misc/is-renote.ts b/packages/backend/test/unit/misc/is-renote.ts
index 74d17abcb6..3c628d8298 100644
--- a/packages/backend/test/unit/misc/is-renote.ts
+++ b/packages/backend/test/unit/misc/is-renote.ts
@@ -44,6 +44,7 @@ const base: MiNote = {
replyUserHost: null,
renoteUserId: null,
renoteUserHost: null,
+ renoteChannelId: null,
};
describe('misc:is-renote', () => {
diff --git a/packages/frontend/src/pages/channel.vue b/packages/frontend/src/pages/channel.vue
index 7c19e6798d..dff8be2a57 100644
--- a/packages/frontend/src/pages/channel.vue
+++ b/packages/frontend/src/pages/channel.vue
@@ -129,24 +129,25 @@ useInterval(() => {
});
watch(() => props.channelId, async () => {
- channel.value = await misskeyApi('channels/show', {
+ const _channel = await misskeyApi('channels/show', {
channelId: props.channelId,
});
- if (channel.value == null) return; // TSを黙らすため
- favorited.value = channel.value.isFavorited ?? false;
- if (favorited.value || channel.value.isFollowing) {
+ favorited.value = _channel.isFavorited ?? false;
+ if (favorited.value || _channel.isFollowing) {
tab.value = 'timeline';
}
- if ((favorited.value || channel.value.isFollowing) && channel.value.lastNotedAt) {
- const lastReadedAt: number = miLocalStorage.getItemAsJson(`channelLastReadedAt:${channel.value.id}`) ?? 0;
- const lastNotedAt = Date.parse(channel.value.lastNotedAt);
+ if ((favorited.value || _channel.isFollowing) && _channel.lastNotedAt) {
+ const lastReadedAt: number = miLocalStorage.getItemAsJson(`channelLastReadedAt:${_channel.id}`) ?? 0;
+ const lastNotedAt = Date.parse(_channel.lastNotedAt);
if (lastNotedAt > lastReadedAt) {
- miLocalStorage.setItemAsJson(`channelLastReadedAt:${channel.value.id}`, lastNotedAt);
+ miLocalStorage.setItemAsJson(`channelLastReadedAt:${_channel.id}`, lastNotedAt);
}
}
+
+ channel.value = _channel;
}, { immediate: true });
function edit() {
@@ -190,6 +191,53 @@ async function unfavorite() {
});
}
+async function mute() {
+ if (!channel.value) return;
+ const _channel = channel.value;
+
+ const { canceled, result: period } = await os.select({
+ title: i18n.ts.mutePeriod,
+ items: [{
+ value: 'indefinitely', text: i18n.ts.indefinitely,
+ }, {
+ value: 'tenMinutes', text: i18n.ts.tenMinutes,
+ }, {
+ value: 'oneHour', text: i18n.ts.oneHour,
+ }, {
+ value: 'oneDay', text: i18n.ts.oneDay,
+ }, {
+ value: 'oneWeek', text: i18n.ts.oneWeek,
+ }],
+ default: 'indefinitely',
+ });
+ if (canceled) return;
+
+ const expiresAt = period === 'indefinitely' ? null
+ : period === 'tenMinutes' ? Date.now() + (1000 * 60 * 10)
+ : period === 'oneHour' ? Date.now() + (1000 * 60 * 60)
+ : period === 'oneDay' ? Date.now() + (1000 * 60 * 60 * 24)
+ : period === 'oneWeek' ? Date.now() + (1000 * 60 * 60 * 24 * 7)
+ : null;
+
+ os.apiWithDialog('channels/mute/create', {
+ channelId: _channel.id,
+ expiresAt,
+ }).then(() => {
+ _channel.isMuting = true;
+ });
+}
+
+async function unmute() {
+ if (!channel.value) return;
+ const _channel = channel.value;
+
+ os.apiWithDialog('channels/mute/delete', {
+ channelId: _channel.id,
+ }).then(() => {
+ _channel.isMuting = false;
+ });
+}
+
async function search() {
if (!channel.value) return;
@@ -243,6 +291,24 @@ const headerActions = computed(() => {
});
}
+ if (!channel.value.isMuting) {
+ headerItems.push({
+ icon: 'ti ti-volume',
+ text: i18n.ts.mute,
+ handler: async (): Promise<void> => {
+ await mute();
+ },
+ });
+ } else {
+ headerItems.push({
+ icon: 'ti ti-volume-off',
+ text: i18n.ts.unmute,
+ handler: async (): Promise<void> => {
+ await unmute();
+ },
+ });
+ }
+
if (($i && $i.id === channel.value.userId) || iAmModerator) {
headerItems.push({
icon: 'ti ti-settings',
diff --git a/packages/misskey-js/etc/misskey-js.api.md b/packages/misskey-js/etc/misskey-js.api.md
index 32af619a49..bb490c178b 100644
--- a/packages/misskey-js/etc/misskey-js.api.md
+++ b/packages/misskey-js/etc/misskey-js.api.md
@@ -939,6 +939,15 @@ type ChannelsFollowedResponse = operations['channels___followed']['responses']['
type ChannelsFollowRequest = operations['channels___follow']['requestBody']['content']['application/json'];
// @public (undocumented)
+type ChannelsMuteCreateRequest = operations['channels___mute___create']['requestBody']['content']['application/json'];
+
+// @public (undocumented)
+type ChannelsMuteDeleteRequest = operations['channels___mute___delete']['requestBody']['content']['application/json'];
+
+// @public (undocumented)
+type ChannelsMuteListResponse = operations['channels___mute___list']['responses']['200']['content']['application/json'];
+
+// @public (undocumented)
type ChannelsMyFavoritesResponse = operations['channels___my-favorites']['responses']['200']['content']['application/json'];
// @public (undocumented)
@@ -1678,6 +1687,9 @@ declare namespace entities {
ChannelsFollowRequest,
ChannelsFollowedRequest,
ChannelsFollowedResponse,
+ ChannelsMuteCreateRequest,
+ ChannelsMuteDeleteRequest,
+ ChannelsMuteListResponse,
ChannelsMyFavoritesResponse,
ChannelsOwnedRequest,
ChannelsOwnedResponse,
diff --git a/packages/misskey-js/generator/package.json b/packages/misskey-js/generator/package.json
index 21ff792f99..7c276e93c7 100644
--- a/packages/misskey-js/generator/package.json
+++ b/packages/misskey-js/generator/package.json
@@ -15,7 +15,8 @@
"openapi-typescript": "7.9.1",
"ts-case-convert": "2.1.0",
"tsx": "4.20.6",
- "typescript": "5.9.3"
+ "typescript": "5.9.3",
+ "eslint": "9.27.0"
},
"files": [
"built"
diff --git a/packages/misskey-js/src/autogen/apiClientJSDoc.ts b/packages/misskey-js/src/autogen/apiClientJSDoc.ts
index c4428efcc2..af3a09a16e 100644
--- a/packages/misskey-js/src/autogen/apiClientJSDoc.ts
+++ b/packages/misskey-js/src/autogen/apiClientJSDoc.ts
@@ -1394,6 +1394,39 @@ declare module '../api.js' {
/**
* No description provided.
*
+ * **Credential required**: *Yes* / **Permission**: *write:channels*
+ */
+ request<E extends 'channels/mute/create', P extends Endpoints[E]['req']>(
+ endpoint: E,
+ params: P,
+ credential?: string | null,
+ ): Promise<SwitchCaseResponseType<E, P>>;
+
+ /**
+ * No description provided.
+ *
+ * **Credential required**: *Yes* / **Permission**: *write:channels*
+ */
+ request<E extends 'channels/mute/delete', P extends Endpoints[E]['req']>(
+ endpoint: E,
+ params: P,
+ credential?: string | null,
+ ): Promise<SwitchCaseResponseType<E, P>>;
+
+ /**
+ * No description provided.
+ *
+ * **Credential required**: *Yes* / **Permission**: *read:channels*
+ */
+ request<E extends 'channels/mute/list', P extends Endpoints[E]['req']>(
+ endpoint: E,
+ params: P,
+ credential?: string | null,
+ ): Promise<SwitchCaseResponseType<E, P>>;
+
+ /**
+ * No description provided.
+ *
* **Credential required**: *Yes* / **Permission**: *read:channels*
*/
request<E extends 'channels/my-favorites', P extends Endpoints[E]['req']>(
diff --git a/packages/misskey-js/src/autogen/endpoint.ts b/packages/misskey-js/src/autogen/endpoint.ts
index 4b83a9dd9b..c3ef3de4e6 100644
--- a/packages/misskey-js/src/autogen/endpoint.ts
+++ b/packages/misskey-js/src/autogen/endpoint.ts
@@ -182,6 +182,9 @@ import type {
ChannelsFollowRequest,
ChannelsFollowedRequest,
ChannelsFollowedResponse,
+ ChannelsMuteCreateRequest,
+ ChannelsMuteDeleteRequest,
+ ChannelsMuteListResponse,
ChannelsMyFavoritesResponse,
ChannelsOwnedRequest,
ChannelsOwnedResponse,
@@ -782,6 +785,9 @@ export type Endpoints = {
'channels/featured': { req: EmptyRequest; res: ChannelsFeaturedResponse };
'channels/follow': { req: ChannelsFollowRequest; res: EmptyResponse };
'channels/followed': { req: ChannelsFollowedRequest; res: ChannelsFollowedResponse };
+ 'channels/mute/create': { req: ChannelsMuteCreateRequest; res: EmptyResponse };
+ 'channels/mute/delete': { req: ChannelsMuteDeleteRequest; res: EmptyResponse };
+ 'channels/mute/list': { req: EmptyRequest; res: ChannelsMuteListResponse };
'channels/my-favorites': { req: EmptyRequest; res: ChannelsMyFavoritesResponse };
'channels/owned': { req: ChannelsOwnedRequest; res: ChannelsOwnedResponse };
'channels/search': { req: ChannelsSearchRequest; res: ChannelsSearchResponse };
diff --git a/packages/misskey-js/src/autogen/entities.ts b/packages/misskey-js/src/autogen/entities.ts
index 4ebe9a5155..0d57b065dc 100644
--- a/packages/misskey-js/src/autogen/entities.ts
+++ b/packages/misskey-js/src/autogen/entities.ts
@@ -185,6 +185,9 @@ export type ChannelsFeaturedResponse = operations['channels___featured']['respon
export type ChannelsFollowRequest = operations['channels___follow']['requestBody']['content']['application/json'];
export type ChannelsFollowedRequest = operations['channels___followed']['requestBody']['content']['application/json'];
export type ChannelsFollowedResponse = operations['channels___followed']['responses']['200']['content']['application/json'];
+export type ChannelsMuteCreateRequest = operations['channels___mute___create']['requestBody']['content']['application/json'];
+export type ChannelsMuteDeleteRequest = operations['channels___mute___delete']['requestBody']['content']['application/json'];
+export type ChannelsMuteListResponse = operations['channels___mute___list']['responses']['200']['content']['application/json'];
export type ChannelsMyFavoritesResponse = operations['channels___my-favorites']['responses']['200']['content']['application/json'];
export type ChannelsOwnedRequest = operations['channels___owned']['requestBody']['content']['application/json'];
export type ChannelsOwnedResponse = operations['channels___owned']['responses']['200']['content']['application/json'];
diff --git a/packages/misskey-js/src/autogen/types.ts b/packages/misskey-js/src/autogen/types.ts
index 3e95651071..4867854b20 100644
--- a/packages/misskey-js/src/autogen/types.ts
+++ b/packages/misskey-js/src/autogen/types.ts
@@ -1140,6 +1140,33 @@ export type paths = {
*/
post: operations['channels___followed'];
};
+ '/channels/mute/create': {
+ /**
+ * channels/mute/create
+ * @description No description provided.
+ *
+ * **Credential required**: *Yes* / **Permission**: *write:channels*
+ */
+ post: operations['channels___mute___create'];
+ };
+ '/channels/mute/delete': {
+ /**
+ * channels/mute/delete
+ * @description No description provided.
+ *
+ * **Credential required**: *Yes* / **Permission**: *write:channels*
+ */
+ post: operations['channels___mute___delete'];
+ };
+ '/channels/mute/list': {
+ /**
+ * channels/mute/list
+ * @description No description provided.
+ *
+ * **Credential required**: *Yes* / **Permission**: *read:channels*
+ */
+ post: operations['channels___mute___list'];
+ };
'/channels/my-favorites': {
/**
* channels/my-favorites
@@ -4929,6 +4956,7 @@ export type components = {
allowRenoteToExternal: boolean;
isFollowing?: boolean;
isFavorited?: boolean;
+ isMuting?: boolean;
pinnedNotes?: components['schemas']['Note'][];
};
QueueCount: {
@@ -14790,6 +14818,192 @@ export interface operations {
};
};
};
+ channels___mute___create: {
+ requestBody: {
+ content: {
+ 'application/json': {
+ /** Format: misskey:id */
+ channelId: string;
+ /** @description A Unix Epoch timestamp that must lie in the future. `null` means an indefinite mute. */
+ expiresAt?: number | null;
+ };
+ };
+ };
+ responses: {
+ /** @description OK (without any results) */
+ 204: {
+ headers: {
+ [name: string]: unknown;
+ };
+ };
+ /** @description Client error */
+ 400: {
+ headers: {
+ [name: string]: unknown;
+ };
+ content: {
+ 'application/json': components['schemas']['Error'];
+ };
+ };
+ /** @description Authentication error */
+ 401: {
+ headers: {
+ [name: string]: unknown;
+ };
+ content: {
+ 'application/json': components['schemas']['Error'];
+ };
+ };
+ /** @description Forbidden error */
+ 403: {
+ headers: {
+ [name: string]: unknown;
+ };
+ content: {
+ 'application/json': components['schemas']['Error'];
+ };
+ };
+ /** @description I'm Ai */
+ 418: {
+ headers: {
+ [name: string]: unknown;
+ };
+ content: {
+ 'application/json': components['schemas']['Error'];
+ };
+ };
+ /** @description Internal server error */
+ 500: {
+ headers: {
+ [name: string]: unknown;
+ };
+ content: {
+ 'application/json': components['schemas']['Error'];
+ };
+ };
+ };
+ };
+ channels___mute___delete: {
+ requestBody: {
+ content: {
+ 'application/json': {
+ /** Format: misskey:id */
+ channelId: string;
+ };
+ };
+ };
+ responses: {
+ /** @description OK (without any results) */
+ 204: {
+ headers: {
+ [name: string]: unknown;
+ };
+ };
+ /** @description Client error */
+ 400: {
+ headers: {
+ [name: string]: unknown;
+ };
+ content: {
+ 'application/json': components['schemas']['Error'];
+ };
+ };
+ /** @description Authentication error */
+ 401: {
+ headers: {
+ [name: string]: unknown;
+ };
+ content: {
+ 'application/json': components['schemas']['Error'];
+ };
+ };
+ /** @description Forbidden error */
+ 403: {
+ headers: {
+ [name: string]: unknown;
+ };
+ content: {
+ 'application/json': components['schemas']['Error'];
+ };
+ };
+ /** @description I'm Ai */
+ 418: {
+ headers: {
+ [name: string]: unknown;
+ };
+ content: {
+ 'application/json': components['schemas']['Error'];
+ };
+ };
+ /** @description Internal server error */
+ 500: {
+ headers: {
+ [name: string]: unknown;
+ };
+ content: {
+ 'application/json': components['schemas']['Error'];
+ };
+ };
+ };
+ };
+ channels___mute___list: {
+ responses: {
+ /** @description OK (with results) */
+ 200: {
+ headers: {
+ [name: string]: unknown;
+ };
+ content: {
+ 'application/json': components['schemas']['Channel'][];
+ };
+ };
+ /** @description Client error */
+ 400: {
+ headers: {
+ [name: string]: unknown;
+ };
+ content: {
+ 'application/json': components['schemas']['Error'];
+ };
+ };
+ /** @description Authentication error */
+ 401: {
+ headers: {
+ [name: string]: unknown;
+ };
+ content: {
+ 'application/json': components['schemas']['Error'];
+ };
+ };
+ /** @description Forbidden error */
+ 403: {
+ headers: {
+ [name: string]: unknown;
+ };
+ content: {
+ 'application/json': components['schemas']['Error'];
+ };
+ };
+ /** @description I'm Ai */
+ 418: {
+ headers: {
+ [name: string]: unknown;
+ };
+ content: {
+ 'application/json': components['schemas']['Error'];
+ };
+ };
+ /** @description Internal server error */
+ 500: {
+ headers: {
+ [name: string]: unknown;
+ };
+ content: {
+ 'application/json': components['schemas']['Error'];
+ };
+ };
+ };
+ };
'channels___my-favorites': {
responses: {
/** @description OK (with results) */
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 6e45b17726..b0b82e0251 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -1478,10 +1478,13 @@ importers:
version: 24.9.1
'@typescript-eslint/eslint-plugin':
specifier: 8.46.1
- version: 8.46.1(@typescript-eslint/parser@8.46.1(eslint@9.37.0)(typescript@5.9.3))(eslint@9.37.0)(typescript@5.9.3)
+ version: 8.46.1(@typescript-eslint/parser@8.46.1(eslint@9.27.0)(typescript@5.9.3))(eslint@9.27.0)(typescript@5.9.3)
'@typescript-eslint/parser':
specifier: 8.46.1
- version: 8.46.1(eslint@9.37.0)(typescript@5.9.3)
+ version: 8.46.1(eslint@9.27.0)(typescript@5.9.3)
+ eslint:
+ specifier: 9.27.0
+ version: 9.27.0
openapi-types:
specifier: 12.1.3
version: 12.1.3
@@ -2274,14 +2277,30 @@ packages:
resolution: {integrity: sha512-lpHyRyplhGPL5mGEh6M9O5nnKk0Gz4bFI+Zu6tKlPpDUN7XshWvH9C/px4UVm87IAANE0W81CEsNGbS1KlzXpA==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
+ '@eslint/config-array@0.20.1':
+ resolution: {integrity: sha512-OL0RJzC/CBzli0DrrR31qzj6d6i6Mm3HByuhflhl4LOBiWxN+3i6/t/ZQQNii4tjksXi8r2CRW1wMpWA2ULUEw==}
+ engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
+
'@eslint/config-array@0.21.0':
resolution: {integrity: sha512-ENIdc4iLu0d93HeYirvKmrzshzofPw6VkZRKQGe9Nv46ZnWUzcF1xV01dcvEg/1wXUR61OmmlSfyeyO7EvjLxQ==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
+ '@eslint/config-helpers@0.2.3':
+ resolution: {integrity: sha512-u180qk2Um1le4yf0ruXH3PYFeEZeYC3p/4wCTKrr2U1CmGdzGi3KtY0nuPDH48UJxlKCC5RDzbcbh4X0XlqgHg==}
+ engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
+
'@eslint/config-helpers@0.4.0':
resolution: {integrity: sha512-WUFvV4WoIwW8Bv0KeKCIIEgdSiFOsulyN0xrMu+7z43q/hkOLXjvb5u7UC9jDxvRzcrbEmuZBX5yJZz1741jog==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
+ '@eslint/core@0.14.0':
+ resolution: {integrity: sha512-qIbV0/JZr7iSDjqAc60IqbLdsj9GDt16xQtWD+B78d/HAlvysGdZZ6rpJHGAc2T0FQx1X6thsSPdnoiGKdNtdg==}
+ engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
+
+ '@eslint/core@0.15.2':
+ resolution: {integrity: sha512-78Md3/Rrxh83gCxoUc0EiciuOHsIITzLy53m3d9UyiW8y9Dj2D29FeETqyKA+BRK76tnTp6RXWb3pCay8Oyomg==}
+ engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
+
'@eslint/core@0.16.0':
resolution: {integrity: sha512-nmC8/totwobIiFcGkDza3GIKfAw1+hLiYVrh3I1nIomQ8PEr5cxg34jnkmGawul/ep52wGRAcyeDCNtWKSOj4Q==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
@@ -2290,6 +2309,10 @@ packages:
resolution: {integrity: sha512-gtF186CXhIl1p4pJNGZw8Yc6RlshoePRvE0X91oPGb3vZ8pM3qOS9W9NGPat9LziaBV7XrJWGylNQXkGcnM3IQ==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
+ '@eslint/js@9.27.0':
+ resolution: {integrity: sha512-G5JD9Tu5HJEu4z2Uo4aHY2sLV64B7CDMXxFzqzjl3NKd6RVzSXNoE80jk7Y0lJkTTkjiIhBAqmlYwjuBY3tvpA==}
+ engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
+
'@eslint/js@9.37.0':
resolution: {integrity: sha512-jaS+NJ+hximswBG6pjNX0uEJZkrT0zwpVi3BA3vX22aFGjJjmgSTSmPpZCRKmoBL5VY/M6p0xsSJx7rk7sy5gg==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
@@ -2298,6 +2321,10 @@ packages:
resolution: {integrity: sha512-RBMg5FRL0I0gs51M/guSAj5/e14VQ4tpZnQNWwuDT66P14I43ItmPfIZRhO9fUVIPOAQXU47atlywZ/czoqFPA==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
+ '@eslint/plugin-kit@0.3.5':
+ resolution: {integrity: sha512-Z5kJ+wU3oA7MMIqVR9tyZRtjYPr4OC004Q4Rw7pgOKUOKkJfZ3O24nz3WYfGRpMDNmcOi3TwQOmgm7B7Tpii0w==}
+ engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
+
'@eslint/plugin-kit@0.4.0':
resolution: {integrity: sha512-sB5uyeq+dwCWyPi31B2gQlVlo+j5brPlWx4yZBrEaRo/nhdDE8Xke1gsGgtiBdaBTxuTkceLVuVt/pclrasb0A==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
@@ -6420,6 +6447,16 @@ packages:
resolution: {integrity: sha512-Uhdk5sfqcee/9H/rCOJikYz67o0a2Tw2hGRPOG2Y1R2dg7brRe1uG0yaNQDHu+TO/uQPF/5eCapvYSmHUjt7JQ==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
+ eslint@9.27.0:
+ resolution: {integrity: sha512-ixRawFQuMB9DZ7fjU3iGGganFDp3+45bPOdaRurcFHSXO1e/sYwUX/FtQZpLZJR6SjMoJH8hR2pPEAfDyCoU2Q==}
+ engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
+ hasBin: true
+ peerDependencies:
+ jiti: '*'
+ peerDependenciesMeta:
+ jiti:
+ optional: true
+
eslint@9.37.0:
resolution: {integrity: sha512-XyLmROnACWqSxiGYArdef1fItQd47weqB7iwtfr9JHwRrqIXZdcFMvvEcL9xHCmL0SNsOvF0c42lWyM1U5dgig==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
@@ -12394,6 +12431,11 @@ snapshots:
'@esbuild/win32-x64@0.25.10':
optional: true
+ '@eslint-community/eslint-utils@4.9.0(eslint@9.27.0)':
+ dependencies:
+ eslint: 9.27.0
+ eslint-visitor-keys: 3.4.3
+
'@eslint-community/eslint-utils@4.9.0(eslint@9.37.0)':
dependencies:
eslint: 9.37.0
@@ -12403,6 +12445,14 @@ snapshots:
'@eslint/compat@1.1.1': {}
+ '@eslint/config-array@0.20.1':
+ dependencies:
+ '@eslint/object-schema': 2.1.6
+ debug: 4.4.3(supports-color@10.2.0)
+ minimatch: 3.1.2
+ transitivePeerDependencies:
+ - supports-color
+
'@eslint/config-array@0.21.0':
dependencies:
'@eslint/object-schema': 2.1.6
@@ -12411,10 +12461,20 @@ snapshots:
transitivePeerDependencies:
- supports-color
+ '@eslint/config-helpers@0.2.3': {}
+
'@eslint/config-helpers@0.4.0':
dependencies:
'@eslint/core': 0.16.0
+ '@eslint/core@0.14.0':
+ dependencies:
+ '@types/json-schema': 7.0.15
+
+ '@eslint/core@0.15.2':
+ dependencies:
+ '@types/json-schema': 7.0.15
+
'@eslint/core@0.16.0':
dependencies:
'@types/json-schema': 7.0.15
@@ -12433,10 +12493,17 @@ snapshots:
transitivePeerDependencies:
- supports-color
+ '@eslint/js@9.27.0': {}
+
'@eslint/js@9.37.0': {}
'@eslint/object-schema@2.1.6': {}
+ '@eslint/plugin-kit@0.3.5':
+ dependencies:
+ '@eslint/core': 0.15.2
+ levn: 0.4.1
+
'@eslint/plugin-kit@0.4.0':
dependencies:
'@eslint/core': 0.16.0
@@ -15251,6 +15318,23 @@ snapshots:
'@types/node': 24.9.1
optional: true
+ '@typescript-eslint/eslint-plugin@8.46.1(@typescript-eslint/parser@8.46.1(eslint@9.27.0)(typescript@5.9.3))(eslint@9.27.0)(typescript@5.9.3)':
+ dependencies:
+ '@eslint-community/regexpp': 4.12.1
+ '@typescript-eslint/parser': 8.46.1(eslint@9.27.0)(typescript@5.9.3)
+ '@typescript-eslint/scope-manager': 8.46.1
+ '@typescript-eslint/type-utils': 8.46.1(eslint@9.27.0)(typescript@5.9.3)
+ '@typescript-eslint/utils': 8.46.1(eslint@9.27.0)(typescript@5.9.3)
+ '@typescript-eslint/visitor-keys': 8.46.1
+ eslint: 9.27.0
+ graphemer: 1.4.0
+ ignore: 7.0.5
+ natural-compare: 1.4.0
+ ts-api-utils: 2.1.0(typescript@5.9.3)
+ typescript: 5.9.3
+ transitivePeerDependencies:
+ - supports-color
+
'@typescript-eslint/eslint-plugin@8.46.1(@typescript-eslint/parser@8.46.1(eslint@9.37.0)(typescript@5.9.3))(eslint@9.37.0)(typescript@5.9.3)':
dependencies:
'@eslint-community/regexpp': 4.12.1
@@ -15268,6 +15352,18 @@ snapshots:
transitivePeerDependencies:
- supports-color
+ '@typescript-eslint/parser@8.46.1(eslint@9.27.0)(typescript@5.9.3)':
+ dependencies:
+ '@typescript-eslint/scope-manager': 8.46.1
+ '@typescript-eslint/types': 8.46.1
+ '@typescript-eslint/typescript-estree': 8.46.1(typescript@5.9.3)
+ '@typescript-eslint/visitor-keys': 8.46.1
+ debug: 4.4.3(supports-color@10.2.0)
+ eslint: 9.27.0
+ typescript: 5.9.3
+ transitivePeerDependencies:
+ - supports-color
+
'@typescript-eslint/parser@8.46.1(eslint@9.37.0)(typescript@5.9.3)':
dependencies:
'@typescript-eslint/scope-manager': 8.46.1
@@ -15298,6 +15394,18 @@ snapshots:
dependencies:
typescript: 5.9.3
+ '@typescript-eslint/type-utils@8.46.1(eslint@9.27.0)(typescript@5.9.3)':
+ dependencies:
+ '@typescript-eslint/types': 8.46.1
+ '@typescript-eslint/typescript-estree': 8.46.1(typescript@5.9.3)
+ '@typescript-eslint/utils': 8.46.1(eslint@9.27.0)(typescript@5.9.3)
+ debug: 4.4.3(supports-color@10.2.0)
+ eslint: 9.27.0
+ ts-api-utils: 2.1.0(typescript@5.9.3)
+ typescript: 5.9.3
+ transitivePeerDependencies:
+ - supports-color
+
'@typescript-eslint/type-utils@8.46.1(eslint@9.37.0)(typescript@5.9.3)':
dependencies:
'@typescript-eslint/types': 8.46.1
@@ -15328,6 +15436,17 @@ snapshots:
transitivePeerDependencies:
- supports-color
+ '@typescript-eslint/utils@8.46.1(eslint@9.27.0)(typescript@5.9.3)':
+ dependencies:
+ '@eslint-community/eslint-utils': 4.9.0(eslint@9.27.0)
+ '@typescript-eslint/scope-manager': 8.46.1
+ '@typescript-eslint/types': 8.46.1
+ '@typescript-eslint/typescript-estree': 8.46.1(typescript@5.9.3)
+ eslint: 9.27.0
+ typescript: 5.9.3
+ transitivePeerDependencies:
+ - supports-color
+
'@typescript-eslint/utils@8.46.1(eslint@9.37.0)(typescript@5.9.3)':
dependencies:
'@eslint-community/eslint-utils': 4.9.0(eslint@9.37.0)
@@ -17322,6 +17441,46 @@ snapshots:
eslint-visitor-keys@4.2.1: {}
+ eslint@9.27.0:
+ dependencies:
+ '@eslint-community/eslint-utils': 4.9.0(eslint@9.27.0)
+ '@eslint-community/regexpp': 4.12.1
+ '@eslint/config-array': 0.20.1
+ '@eslint/config-helpers': 0.2.3
+ '@eslint/core': 0.14.0
+ '@eslint/eslintrc': 3.3.1
+ '@eslint/js': 9.27.0
+ '@eslint/plugin-kit': 0.3.5
+ '@humanfs/node': 0.16.7
+ '@humanwhocodes/module-importer': 1.0.1
+ '@humanwhocodes/retry': 0.4.3
+ '@types/estree': 1.0.8
+ '@types/json-schema': 7.0.15
+ ajv: 6.12.6
+ chalk: 4.1.2
+ cross-spawn: 7.0.6
+ debug: 4.4.3(supports-color@10.2.0)
+ escape-string-regexp: 4.0.0
+ eslint-scope: 8.4.0
+ eslint-visitor-keys: 4.2.1
+ espree: 10.4.0
+ esquery: 1.6.0
+ esutils: 2.0.3
+ fast-deep-equal: 3.1.3
+ file-entry-cache: 8.0.0
+ find-up: 5.0.0
+ glob-parent: 6.0.2
+ ignore: 5.3.2
+ imurmurhash: 0.1.4
+ is-glob: 4.0.3
+ json-stable-stringify-without-jsonify: 1.0.1
+ lodash.merge: 4.6.2
+ minimatch: 3.1.2
+ natural-compare: 1.4.0
+ optionator: 0.9.4
+ transitivePeerDependencies:
+ - supports-color
+
eslint@9.37.0:
dependencies:
'@eslint-community/eslint-utils': 4.9.0(eslint@9.37.0)