From 2fda599a86a430eddbe038b6cc81f8c536f7befb Mon Sep 17 00:00:00 2001 From: Johann150 Date: Sun, 19 Feb 2023 18:13:08 +0100 Subject: [PATCH] client: adjust API endpoints for user administration --- packages/client/src/components/abuse-report.vue | 2 +- packages/client/src/pages/admin/abuses.vue | 2 +- packages/client/src/pages/admin/index.vue | 2 +- packages/client/src/pages/admin/users.vue | 4 ++-- packages/client/src/pages/instance-info.vue | 2 +- packages/client/src/pages/user-info.vue | 12 ++++++------ packages/client/src/pages/welcome.setup.vue | 2 +- packages/client/src/scripts/get-user-menu.ts | 4 ++-- 8 files changed, 15 insertions(+), 15 deletions(-) diff --git a/packages/client/src/components/abuse-report.vue b/packages/client/src/components/abuse-report.vue index c723a7b63..21ab67497 100644 --- a/packages/client/src/components/abuse-report.vue +++ b/packages/client/src/components/abuse-report.vue @@ -61,7 +61,7 @@ const emit = defineEmits<{ let forward = $ref(props.report.forwarded); function resolve(): void { - os.apiWithDialog('admin/resolve-abuse-user-report', { + os.apiWithDialog('admin/reports/resolve', { forward, reportId: props.report.id, }).then(() => { diff --git a/packages/client/src/pages/admin/abuses.vue b/packages/client/src/pages/admin/abuses.vue index f38f70248..43fad4e87 100644 --- a/packages/client/src/pages/admin/abuses.vue +++ b/packages/client/src/pages/admin/abuses.vue @@ -52,7 +52,7 @@ let reporterOrigin = $ref('combined'); let targetUserOrigin = $ref('combined'); const pagination = { - endpoint: 'admin/abuse-user-reports' as const, + endpoint: 'admin/reports/list' as const, limit: 10, params: computed(() => ({ state, diff --git a/packages/client/src/pages/admin/index.vue b/packages/client/src/pages/admin/index.vue index 289f4fd29..bee7c6e13 100644 --- a/packages/client/src/pages/admin/index.vue +++ b/packages/client/src/pages/admin/index.vue @@ -61,7 +61,7 @@ let noBotProtection = !instance.disableRegistration && !instance.enableHcaptcha let noEmailServer = !instance.enableEmail; let thereIsUnresolvedAbuseReport = $ref(false); -os.api('admin/abuse-user-reports', { +os.api('admin/reports/list', { state: 'unresolved', limit: 1, }).then(reports => { diff --git a/packages/client/src/pages/admin/users.vue b/packages/client/src/pages/admin/users.vue index 6efd2979b..b9d832772 100644 --- a/packages/client/src/pages/admin/users.vue +++ b/packages/client/src/pages/admin/users.vue @@ -71,7 +71,7 @@ let origin = $ref('local'); let searchUsername = $ref(''); let searchHost = $ref(''); const pagination = { - endpoint: 'admin/show-users' as const, + endpoint: 'admin/users' as const, limit: 10, params: computed(() => ({ sort, @@ -101,7 +101,7 @@ async function addUser(): Promise { }); if (canceled2) return; - os.apiWithDialog('admin/accounts/create', { + os.apiWithDialog('admin/users/create', { username, password, }).then(() => { diff --git a/packages/client/src/pages/instance-info.vue b/packages/client/src/pages/instance-info.vue index 0e0d94641..6dd4ede57 100644 --- a/packages/client/src/pages/instance-info.vue +++ b/packages/client/src/pages/instance-info.vue @@ -166,7 +166,7 @@ let suspended = $ref(false); let isBlocked = $ref(false); const usersPagination = { - endpoint: iAmModerator ? 'admin/show-users' : 'users' as const, + endpoint: iAmModerator ? 'admin/users' : 'users' as const, limit: 10, params: { sort: '+updatedAt', diff --git a/packages/client/src/pages/user-info.vue b/packages/client/src/pages/user-info.vue index cce7f2efa..2bca72c2f 100644 --- a/packages/client/src/pages/user-info.vue +++ b/packages/client/src/pages/user-info.vue @@ -149,7 +149,7 @@ function createFetcher() { if (iAmModerator) { return () => Promise.all([os.api('users/show', { userId: props.userId, - }), os.api('admin/show-user', { + }), os.api('admin/users/show', { userId: props.userId, })]).then(([_user, _info]) => { user = _user; @@ -177,7 +177,7 @@ async function updateRemoteUser() { } async function resetPassword() { - const { password } = await os.api('admin/reset-password', { + const { password } = await os.api('admin/users/reset-password', { userId: user.id, }); @@ -195,7 +195,7 @@ async function toggleSilence(v) { if (confirm.canceled) { silenced = !v; } else { - await os.api(v ? 'admin/silence-user' : 'admin/unsilence-user', { userId: user.id }); + await os.api(v ? 'admin/users/silence' : 'admin/users/unsilence', { userId: user.id }); await refreshUser(); } } @@ -208,7 +208,7 @@ async function toggleSuspend(v) { if (confirm.canceled) { suspended = !v; } else { - await os.api(v ? 'admin/suspend-user' : 'admin/unsuspend-user', { userId: user.id }); + await os.api(v ? 'admin/users/suspend' : 'admin/users/unsuspend', { userId: user.id }); await refreshUser(); } } @@ -225,7 +225,7 @@ async function deleteAllFiles() { }); if (confirm.canceled) return; const process = async () => { - await os.api('admin/delete-all-files-of-a-user', { userId: user.id }); + await os.api('admin/users/delete-all-files', { userId: user.id }); os.success(); }; await process().catch(err => { @@ -250,7 +250,7 @@ async function deleteAccount() { if (typed.canceled) return; if (typed.result === user?.username) { - await os.apiWithDialog('admin/accounts/delete', { + await os.apiWithDialog('admin/users/delete', { userId: user.id, }); } else { diff --git a/packages/client/src/pages/welcome.setup.vue b/packages/client/src/pages/welcome.setup.vue index 80bbf5950..c445ba902 100644 --- a/packages/client/src/pages/welcome.setup.vue +++ b/packages/client/src/pages/welcome.setup.vue @@ -35,7 +35,7 @@ function submit(): void { if (submitting) return; submitting = true; - os.api('admin/accounts/create', { + os.api('admin/users/create', { username, password, }).then(res => { diff --git a/packages/client/src/scripts/get-user-menu.ts b/packages/client/src/scripts/get-user-menu.ts index b7072ed25..b0bc3e7f3 100644 --- a/packages/client/src/scripts/get-user-menu.ts +++ b/packages/client/src/scripts/get-user-menu.ts @@ -119,7 +119,7 @@ export function getUserMenu(user) { async function toggleSilence(): Promise { if (!await getConfirmed(i18n.t(user.isSilenced ? 'unsilenceConfirm' : 'silenceConfirm'))) return; - os.apiWithDialog(user.isSilenced ? 'admin/unsilence-user' : 'admin/silence-user', { + os.apiWithDialog(user.isSilenced ? 'admin/users/unsilence' : 'admin/users/silence', { userId: user.id, }).then(() => { user.isSilenced = !user.isSilenced; @@ -129,7 +129,7 @@ export function getUserMenu(user) { async function toggleSuspend(): Promise { if (!await getConfirmed(i18n.t(user.isSuspended ? 'unsuspendConfirm' : 'suspendConfirm'))) return; - os.apiWithDialog(user.isSuspended ? 'admin/unsuspend-user' : 'admin/suspend-user', { + os.apiWithDialog(user.isSuspended ? 'admin/users/unsuspend' : 'admin/users/suspend', { userId: user.id, }).then(() => { user.isSuspended = !user.isSuspended;