From 04104c4068de76c23e4422d1798cb244bde3ddb9 Mon Sep 17 00:00:00 2001 From: mei23 Date: Mon, 12 Feb 2024 18:40:37 +0900 Subject: [PATCH] =?UTF-8?q?=E5=89=8A=E9=99=A4=E3=81=95=E3=82=8C=E3=81=9F/?= =?UTF-8?q?=E5=89=8A=E9=99=A4=E3=81=97=E3=81=9F=E3=83=AA=E3=83=A2=E3=83=BC?= =?UTF-8?q?=E3=83=88=E3=83=A6=E3=83=BC=E3=82=B6=E3=83=BC=E3=82=92=E5=BE=A9?= =?UTF-8?q?=E6=B4=BB=E3=81=95=E3=81=9B=E3=82=8B=E3=83=84=E3=83=BC=E3=83=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/manage.ja.md | 9 ++++++++ src/tools/undelete-remote-user.ts | 37 +++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 src/tools/undelete-remote-user.ts diff --git a/docs/manage.ja.md b/docs/manage.ja.md index 7e24e8c812de..f4ca899ad175 100644 --- a/docs/manage.ja.md +++ b/docs/manage.ja.md @@ -118,3 +118,12 @@ https://github.com/mei23/misskey/issues/4674 のバグで残ってしまったRe ```sh node built/tools/clean-queue-logs.js ``` + +## 削除された/削除したリモートユーザーを復活させる + +リモートからDelete/Undo.Deleteされた または こちらで削除した リモートユーザーを復活させます。 +userIdは管理画面からリモートユーザーを削除済みでフィルタして`_id`を参照します。 + +```sh +node built/tools/undelete-remote-user.js userId +``` diff --git a/src/tools/undelete-remote-user.ts b/src/tools/undelete-remote-user.ts new file mode 100644 index 000000000000..8c288fa99857 --- /dev/null +++ b/src/tools/undelete-remote-user.ts @@ -0,0 +1,37 @@ +import * as mongo from 'mongodb'; +import User, { IRemoteUser } from '../models/user'; +import { updatePerson } from '../remote/activitypub/models/person'; + +async function main(userId: string) { + if (!userId) throw 'userId required'; + const user = await User.findOne({ + _id: new mongo.ObjectID(userId), + host: { $ne: null }, + isDeleted: true + }); + + if (user == null) { + throw `user not found`; + } + + console.log('user', user); + + const result = await User.update({ _id: user._id }, { + $set: { + isDeleted: false, + } + }); + + console.log('result', result); + + await updatePerson((user as IRemoteUser).uri); +} + +const args = process.argv.slice(2); + +main(args[0]).then(() => { + console.log('Done'); + setTimeout(() => { + process.exit(0); + }, 30 * 1000); +});