mirror of
https://github.com/misskey-dev/misskey.git
synced 2024-12-24 00:39:32 +09:00
enhance(moderation): 管理者がアカウントの物理削除・論理削除を選べるように (MisskeyIO#581)
This commit is contained in:
parent
acc10c0709
commit
b4420f895e
@ -37,6 +37,7 @@ export const paramDef = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
userId: { type: 'string', format: 'misskey:id' },
|
||||
soft: { type: 'boolean', default: true, description: 'Since deletion by an administrator is a moderation action, the default is to soft delete.' },
|
||||
},
|
||||
required: ['userId'],
|
||||
} as const;
|
||||
@ -56,8 +57,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||
if (user == null) throw new ApiError(meta.errors.userNotFound);
|
||||
if (await this.roleService.isModerator(user)) throw new ApiError(meta.errors.cannotDeleteModerator);
|
||||
|
||||
// 管理者からの削除ということはモデレーション行為なので、soft delete にする
|
||||
await this.deleteAccountService.deleteAccount(user, true, me);
|
||||
await this.deleteAccountService.deleteAccount(user, ps.soft, me);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -58,11 +58,16 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
<FormSection>
|
||||
<div class="_gaps">
|
||||
<MkSwitch v-model="suspended" @update:modelValue="toggleSuspend">{{ i18n.ts.suspend }}</MkSwitch>
|
||||
|
||||
<div>
|
||||
<MkButton v-if="user.host == null" inline style="margin-right: 8px;" @click="resetPassword"><i class="ti ti-key"></i> {{ i18n.ts.resetPassword }}</MkButton>
|
||||
</div>
|
||||
<MkFolder v-if="iAmModerator" defaultOpen>
|
||||
<template #icon><i class="ti ti-shield"></i></template>
|
||||
<template #label>{{ i18n.ts.moderation }}</template>
|
||||
<div class="_gaps">
|
||||
<MkSwitch v-model="suspended" @update:modelValue="toggleSuspend">{{ i18n.ts.suspend }}</MkSwitch>
|
||||
<MkButton v-if="user.host == null" @click="resetPassword"><i class="ti ti-key"></i> {{ i18n.ts.resetPassword }}</MkButton>
|
||||
<MkButton inline danger @click="unsetUserAvatar"><i class="ti ti-user-circle"></i> {{ i18n.ts.unsetUserAvatar }}</MkButton>
|
||||
<MkButton inline danger @click="unsetUserBanner"><i class="ti ti-photo"></i> {{ i18n.ts.unsetUserBanner }}</MkButton>
|
||||
</div>
|
||||
</MkFolder>
|
||||
|
||||
<MkFolder>
|
||||
<template #icon><i class="ti ti-license"></i></template>
|
||||
@ -87,11 +92,14 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||
</template>
|
||||
</MkFolder>
|
||||
|
||||
<div class="_buttons">
|
||||
<MkButton v-if="iAmModerator" inline danger @click="unsetUserAvatar"><i class="ti ti-user-circle"></i> {{ i18n.ts.unsetUserAvatar }}</MkButton>
|
||||
<MkButton v-if="iAmModerator" inline danger @click="unsetUserBanner"><i class="ti ti-photo"></i> {{ i18n.ts.unsetUserBanner }}</MkButton>
|
||||
</div>
|
||||
<MkButton v-if="$i.isAdmin" inline danger @click="deleteAccount">{{ i18n.ts.deleteAccount }}</MkButton>
|
||||
<MkFolder v-if="$i.isAdmin">
|
||||
<template #icon><i class="ti ti-user-x"></i></template>
|
||||
<template #label>{{ i18n.ts.deleteAccount }}</template>
|
||||
<div class="_gaps">
|
||||
<MkButton inline danger @click="deleteAccount(true)"><i class="ti ti-user-x"></i> {{ i18n.ts.deleteAccount }}</MkButton>
|
||||
<MkButton inline danger @click="deleteAccount(false)"><i class="ti ti-file-shredder"></i> {{ i18n.ts.deleteAccount }} ({{ i18n.ts.all }})</MkButton>
|
||||
</div>
|
||||
</MkFolder>
|
||||
</div>
|
||||
</FormSection>
|
||||
</div>
|
||||
@ -380,7 +388,7 @@ async function deleteAllFiles() {
|
||||
}
|
||||
}
|
||||
|
||||
async function deleteAccount() {
|
||||
async function deleteAccount(soft: boolean) {
|
||||
const confirm = await os.confirm({
|
||||
type: 'warning',
|
||||
text: i18n.ts.deleteAccountConfirm,
|
||||
@ -395,6 +403,7 @@ async function deleteAccount() {
|
||||
if (typed.result === user.value?.username) {
|
||||
await os.apiWithDialog('admin/accounts/delete', {
|
||||
userId: user.value.id,
|
||||
soft,
|
||||
}).then(refreshUser);
|
||||
} else {
|
||||
os.alert({
|
||||
|
@ -5438,6 +5438,11 @@ export type operations = {
|
||||
'application/json': {
|
||||
/** Format: misskey:id */
|
||||
userId: string;
|
||||
/**
|
||||
* @description Since deletion by an administrator is a moderation action, the default is to soft delete.
|
||||
* @default true
|
||||
*/
|
||||
soft?: boolean;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user