Skip to content

Commit

Permalink
削除された/削除したリモートユーザーを復活させるツール
Browse files Browse the repository at this point in the history
  • Loading branch information
mei23 committed Feb 12, 2024
1 parent 2e8240e commit 04104c4
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
9 changes: 9 additions & 0 deletions docs/manage.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
37 changes: 37 additions & 0 deletions src/tools/undelete-remote-user.ts
Original file line number Diff line number Diff line change
@@ -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);
});

0 comments on commit 04104c4

Please sign in to comment.