From 6f3e64f13e146ba3bf9b97f0444c7518d98195ab Mon Sep 17 00:00:00 2001 From: syuilo Date: Thu, 30 Jun 2022 15:32:11 +0900 Subject: [PATCH] chore(client): tweak client --- packages/backend/src/server/api/endpoints/users.ts | 10 ++++++++++ packages/client/src/pages/instance-info.vue | 3 +-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/backend/src/server/api/endpoints/users.ts b/packages/backend/src/server/api/endpoints/users.ts index 2377faebd..3a8211374 100644 --- a/packages/backend/src/server/api/endpoints/users.ts +++ b/packages/backend/src/server/api/endpoints/users.ts @@ -27,6 +27,12 @@ export const paramDef = { sort: { type: 'string', enum: ['+follower', '-follower', '+createdAt', '-createdAt', '+updatedAt', '-updatedAt'] }, state: { type: 'string', enum: ['all', 'admin', 'moderator', 'adminOrModerator', 'alive'], default: 'all' }, origin: { type: 'string', enum: ['combined', 'local', 'remote'], default: 'local' }, + hostname: { + type: 'string', + nullable: true, + default: null, + description: 'The local host is represented with `null`.', + }, }, required: [], } as const; @@ -48,6 +54,10 @@ export default define(meta, paramDef, async (ps, me) => { case 'remote': query.andWhere('user.host IS NOT NULL'); break; } + if (ps.hostname) { + query.andWhere('user.host = :hostname', { hostname: ps.hostname.toLowerCase() }); + } + switch (ps.sort) { case '+follower': query.orderBy('user.followersCount', 'DESC'); break; case '-follower': query.orderBy('user.followersCount', 'ASC'); break; diff --git a/packages/client/src/pages/instance-info.vue b/packages/client/src/pages/instance-info.vue index b72fcb152..83f3354df 100644 --- a/packages/client/src/pages/instance-info.vue +++ b/packages/client/src/pages/instance-info.vue @@ -143,12 +143,11 @@ let suspended = $ref(false); let isBlocked = $ref(false); const usersPagination = { - endpoint: 'admin/show-users' as const, + endpoint: iAmModerator ? 'admin/show-users' : 'users' as const, limit: 10, params: { sort: '+updatedAt', state: 'all', - origin: 'remote', hostname: props.host, }, offsetMode: true,