From 96648b651eaab8b37dc809ec48acb09bce834ea1 Mon Sep 17 00:00:00 2001 From: syuilo Date: Thu, 30 Jan 2020 05:56:14 +0900 Subject: [PATCH] isMarkedAsClosed --> isSuspended --- CHANGELOG.md | 1 + migration/1580331224276-v12-11.ts | 18 ++++++++++++++++++ src/models/entities/instance.ts | 5 +++-- src/queue/processors/deliver.ts | 10 +++++----- .../admin/federation/update-instance.ts | 4 ++-- 5 files changed, 29 insertions(+), 9 deletions(-) create mode 100644 migration/1580331224276-v12-11.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b6e2c59a..b3266c52e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ ChangeLog ### Breaking Chnages * お知らせがリセットされます。 * 通知がリセットされます。 +* インスタンスの閉鎖情報がリセットされます。 * モデレーターがインスタンス設定を閲覧したり変更したりできなくなります(それらができるのはAdminのみになります)。 * モデレーターが出来るのは、ユーザーのサイレンス/凍結などに限られます。 * 従来と同じ権限を与えたい場合、モデレーターをAdminに設定することを検討してください(Adminは複数人設定可能です)。 diff --git a/migration/1580331224276-v12-11.ts b/migration/1580331224276-v12-11.ts new file mode 100644 index 000000000..30794b80e --- /dev/null +++ b/migration/1580331224276-v12-11.ts @@ -0,0 +1,18 @@ +import {MigrationInterface, QueryRunner} from "typeorm"; + +export class v12111580331224276 implements MigrationInterface { + name = 'v12111580331224276' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "instance" DROP COLUMN "isMarkedAsClosed"`, undefined); + await queryRunner.query(`ALTER TABLE "instance" ADD "isSuspended" boolean NOT NULL DEFAULT false`, undefined); + await queryRunner.query(`CREATE INDEX "IDX_34500da2e38ac393f7bb6b299c" ON "instance" ("isSuspended") `, undefined); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`DROP INDEX "IDX_34500da2e38ac393f7bb6b299c"`, undefined); + await queryRunner.query(`ALTER TABLE "instance" DROP COLUMN "isSuspended"`, undefined); + await queryRunner.query(`ALTER TABLE "instance" ADD "isMarkedAsClosed" boolean NOT NULL DEFAULT false`, undefined); + } + +} diff --git a/src/models/entities/instance.ts b/src/models/entities/instance.ts index dd0de100d..fe620887d 100644 --- a/src/models/entities/instance.ts +++ b/src/models/entities/instance.ts @@ -114,12 +114,13 @@ export class Instance { public isNotResponding: boolean; /** - * このインスタンスが閉鎖済みとしてマークされているか + * このインスタンスへの配信を停止するか */ + @Index() @Column('boolean', { default: false }) - public isMarkedAsClosed: boolean; + public isSuspended: boolean; @Column('varchar', { length: 64, nullable: true, default: null, diff --git a/src/queue/processors/deliver.ts b/src/queue/processors/deliver.ts index 980ca3a43..16b2f6e29 100644 --- a/src/queue/processors/deliver.ts +++ b/src/queue/processors/deliver.ts @@ -21,15 +21,15 @@ export default async (job: Bull.Job) => { return 'skip (blocked)'; } - // closedなら中断 - const closedHosts = await Instances.find({ + // isSuspendedなら中断 + const suspendedHosts = await Instances.find({ where: { - isMarkedAsClosed: true + isSuspended: true }, cache: 60 * 1000 }); - if (closedHosts.map(x => x.host).includes(toPuny(host))) { - return 'skip (closed)'; + if (suspendedHosts.map(x => x.host).includes(toPuny(host))) { + return 'skip (suspended)'; } try { diff --git a/src/server/api/endpoints/admin/federation/update-instance.ts b/src/server/api/endpoints/admin/federation/update-instance.ts index 90ab7a3ec..88bd2e3df 100644 --- a/src/server/api/endpoints/admin/federation/update-instance.ts +++ b/src/server/api/endpoints/admin/federation/update-instance.ts @@ -14,7 +14,7 @@ export const meta = { validator: $.str }, - isClosed: { + isSuspended: { validator: $.bool }, } @@ -28,6 +28,6 @@ export default define(meta, async (ps, me) => { } Instances.update({ host: toPuny(ps.host) }, { - isMarkedAsClosed: ps.isClosed + isSuspended: ps.isSuspended }); });