From c7ab8839dc78f131827974e351bfdd534d82fae3 Mon Sep 17 00:00:00 2001 From: Johann150 Date: Sat, 7 Jan 2023 19:30:06 +0100 Subject: [PATCH] BREAKING: remove admin/delete-account, change admin/accounts/delete You should use the API endpoint admin/accounts/delete. It has the same parameter and the same behaviour. The admin/accounts/delete endpoint now requries administrator privileges instead of just moderator privileges. Changelog: Removed --- packages/backend/src/server/api/endpoints.ts | 2 -- .../api/endpoints/admin/accounts/delete.ts | 2 +- .../api/endpoints/admin/delete-account.ts | 31 ------------------- packages/client/src/pages/user-info.vue | 2 +- 4 files changed, 2 insertions(+), 35 deletions(-) delete mode 100644 packages/backend/src/server/api/endpoints/admin/delete-account.ts diff --git a/packages/backend/src/server/api/endpoints.ts b/packages/backend/src/server/api/endpoints.ts index 6e69b3b11..59c4305c2 100644 --- a/packages/backend/src/server/api/endpoints.ts +++ b/packages/backend/src/server/api/endpoints.ts @@ -54,7 +54,6 @@ import * as ep___admin_unsilenceUser from './endpoints/admin/unsilence-user.js'; import * as ep___admin_unsuspendUser from './endpoints/admin/unsuspend-user.js'; import * as ep___admin_updateMeta from './endpoints/admin/update-meta.js'; import * as ep___admin_vacuum from './endpoints/admin/vacuum.js'; -import * as ep___admin_deleteAccount from './endpoints/admin/delete-account.js'; import * as ep___announcements from './endpoints/announcements.js'; import * as ep___antennas_create from './endpoints/antennas/create.js'; import * as ep___antennas_delete from './endpoints/antennas/delete.js'; @@ -363,7 +362,6 @@ const eps = [ ['admin/unsuspend-user', ep___admin_unsuspendUser], ['admin/update-meta', ep___admin_updateMeta], ['admin/vacuum', ep___admin_vacuum], - ['admin/delete-account', ep___admin_deleteAccount], ['announcements', ep___announcements], ['antennas/create', ep___antennas_create], ['antennas/delete', ep___antennas_delete], diff --git a/packages/backend/src/server/api/endpoints/admin/accounts/delete.ts b/packages/backend/src/server/api/endpoints/admin/accounts/delete.ts index 19e3cd604..4f5ea5568 100644 --- a/packages/backend/src/server/api/endpoints/admin/accounts/delete.ts +++ b/packages/backend/src/server/api/endpoints/admin/accounts/delete.ts @@ -7,7 +7,7 @@ export const meta = { tags: ['admin'], requireCredential: true, - requireModerator: true, + requireAdmin: true, errors: ['NO_SUCH_USER', 'IS_ADMIN', 'IS_MODERATOR'], } as const; diff --git a/packages/backend/src/server/api/endpoints/admin/delete-account.ts b/packages/backend/src/server/api/endpoints/admin/delete-account.ts deleted file mode 100644 index 2d7ef2f23..000000000 --- a/packages/backend/src/server/api/endpoints/admin/delete-account.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { Users } from '@/models/index.js'; -import { deleteAccount } from '@/services/delete-account.js'; -import define from '../../define.js'; - -export const meta = { - tags: ['admin'], - - requireCredential: true, - requireAdmin: true, - - res: { - }, -} as const; - -export const paramDef = { - type: 'object', - properties: { - userId: { type: 'string', format: 'misskey:id' }, - }, - required: ['userId'], -} as const; - -// eslint-disable-next-line import/no-default-export -export default define(meta, paramDef, async (ps) => { - const user = await Users.findOneByOrFail({ id: ps.userId }); - if (user.isDeleted) { - return; - } - - await deleteAccount(user); -}); diff --git a/packages/client/src/pages/user-info.vue b/packages/client/src/pages/user-info.vue index fa0e22b99..2a4bb1be3 100644 --- a/packages/client/src/pages/user-info.vue +++ b/packages/client/src/pages/user-info.vue @@ -249,7 +249,7 @@ async function deleteAccount() { if (typed.canceled) return; if (typed.result === user?.username) { - await os.apiWithDialog('admin/delete-account', { + await os.apiWithDialog('admin/accounts/delete', { userId: user.id, }); } else {