From b7b30bde5db385205938f32c362a3cd5c7691076 Mon Sep 17 00:00:00 2001 From: Hazelnoot Date: Mon, 12 May 2025 22:43:19 -0400 Subject: [PATCH] use /users endpoint for explore exclusively (restore original behavior) --- locales/index.d.ts | 16 ++++++++-------- .../backend/src/server/api/endpoints/users.ts | 18 ++++++------------ packages/frontend/src/pages/explore.users.vue | 8 -------- packages/misskey-js/src/autogen/types.ts | 2 -- 4 files changed, 14 insertions(+), 30 deletions(-) diff --git a/locales/index.d.ts b/locales/index.d.ts index 1263c48fc2..3316a679e0 100644 --- a/locales/index.d.ts +++ b/locales/index.d.ts @@ -13057,14 +13057,14 @@ export interface Locale extends ILocale { * Users popular on {name} */ "popularUsersLocal": ParameterizedString<"name">; - /** - * Translation timeout - */ - "translationTimeoutLabel": string; - /** - * Timeout in milliseconds for translation API requests. - */ - "translationTimeoutCaption": string; + /** + * Translation timeout + */ + "translationTimeoutLabel": string; + /** + * Timeout in milliseconds for translation API requests. + */ + "translationTimeoutCaption": string; } declare const locales: { [lang: string]: Locale; diff --git a/packages/backend/src/server/api/endpoints/users.ts b/packages/backend/src/server/api/endpoints/users.ts index b7202b71a8..ce1407543d 100644 --- a/packages/backend/src/server/api/endpoints/users.ts +++ b/packages/backend/src/server/api/endpoints/users.ts @@ -50,7 +50,6 @@ export const paramDef = { default: null, description: 'The local host is represented with `null`.', }, - trending: { type: 'boolean', default: false }, }, required: [], } as const; @@ -67,12 +66,9 @@ export default class extends Endpoint { // eslint- ) { super(meta, paramDef, async (ps, me) => { const query = this.usersRepository.createQueryBuilder('user') + .andWhere('user.isExplorable = TRUE') .andWhere('user.isSuspended = FALSE'); - if (ps.trending) { - query.andWhere('user.isExplorable = TRUE'); - } - switch (ps.state) { case 'alive': query.andWhere('user.updatedAt > :date', { date: new Date(Date.now() - 1000 * 60 * 60 * 24 * 5) }); break; } @@ -104,18 +100,16 @@ export default class extends Endpoint { // eslint- query.limit(ps.limit); query.offset(ps.offset); - let users = await query.getMany(); + const allUsers = await query.getMany(); // This is not ideal, for a couple of reasons: // 1. It may return less than "limit" results. // 2. A span of more than "limit" consecutive non-trendable users may cause the pagination to stop early. // Unfortunately, there's no better solution unless we refactor role policies to be persisted to the DB. - if (ps.trending) { - const usersWithRoles = await Promise.all(users.map(async u => [u, await this.roleService.getUserPolicies(u)] as const)); - users = usersWithRoles - .filter(([,p]) => p.canTrend) - .map(([u]) => u); - } + const usersWithRoles = await Promise.all(allUsers.map(async u => [u, await this.roleService.getUserPolicies(u)] as const)); + const users = usersWithRoles + .filter(([,p]) => p.canTrend) + .map(([u]) => u); return await this.userEntityService.packMany(users, me, { schema: 'UserDetailed' }); }); diff --git a/packages/frontend/src/pages/explore.users.vue b/packages/frontend/src/pages/explore.users.vue index e4b1f6e79c..77fe21c33f 100644 --- a/packages/frontend/src/pages/explore.users.vue +++ b/packages/frontend/src/pages/explore.users.vue @@ -97,7 +97,6 @@ const tagUsers = computed(() => ({ tag: props.tag, origin: 'combined', sort: '+follower', - trending: true, }, } as const)); @@ -106,40 +105,33 @@ const popularUsers = { endpoint: 'users', limit: 10, noPaging: true, params: { state: 'alive', origin: 'local', sort: '+follower', - trending: true, } } as const; const recentlyUpdatedUsers = { endpoint: 'users', limit: 10, noPaging: true, params: { origin: 'local', sort: '+updatedAt', - trending: true, } } as const; const recentlyRegisteredUsers = { endpoint: 'users', limit: 10, noPaging: true, params: { origin: 'local', state: 'alive', sort: '+createdAt', - trending: true, } } as const; const popularUsersF = { endpoint: 'users', limit: 10, noPaging: true, params: { state: 'alive', origin: 'remote', sort: '+follower', - trending: true, } } as const; const popularUsersLocalF = { endpoint: 'users', limit: 10, noPaging: true, params: { state: 'alive', origin: 'remote', sort: '+localFollower', - trending: true, } } as const; const recentlyUpdatedUsersF = { endpoint: 'users', limit: 10, noPaging: true, params: { origin: 'combined', sort: '+updatedAt', - trending: true, } } as const; const recentlyRegisteredUsersF = { endpoint: 'users', limit: 10, noPaging: true, params: { origin: 'combined', sort: '+createdAt', - trending: true, } } as const; misskeyApi('hashtags/list', { diff --git a/packages/misskey-js/src/autogen/types.ts b/packages/misskey-js/src/autogen/types.ts index 94509c945e..778b00c66d 100644 --- a/packages/misskey-js/src/autogen/types.ts +++ b/packages/misskey-js/src/autogen/types.ts @@ -31541,8 +31541,6 @@ export type operations = { * @default null */ hostname?: string | null; - /** @default false */ - trending?: boolean; }; }; };