mirror of
https://codeberg.org/yeentown/barkey.git
synced 2025-07-08 04:54:32 +00:00
use /users endpoint for explore exclusively (restore original behavior)
This commit is contained in:
parent
bb8609d0f0
commit
b7b30bde5d
4 changed files with 14 additions and 30 deletions
16
locales/index.d.ts
vendored
16
locales/index.d.ts
vendored
|
@ -13057,14 +13057,14 @@ export interface Locale extends ILocale {
|
||||||
* Users popular on {name}
|
* Users popular on {name}
|
||||||
*/
|
*/
|
||||||
"popularUsersLocal": ParameterizedString<"name">;
|
"popularUsersLocal": ParameterizedString<"name">;
|
||||||
/**
|
/**
|
||||||
* Translation timeout
|
* Translation timeout
|
||||||
*/
|
*/
|
||||||
"translationTimeoutLabel": string;
|
"translationTimeoutLabel": string;
|
||||||
/**
|
/**
|
||||||
* Timeout in milliseconds for translation API requests.
|
* Timeout in milliseconds for translation API requests.
|
||||||
*/
|
*/
|
||||||
"translationTimeoutCaption": string;
|
"translationTimeoutCaption": string;
|
||||||
}
|
}
|
||||||
declare const locales: {
|
declare const locales: {
|
||||||
[lang: string]: Locale;
|
[lang: string]: Locale;
|
||||||
|
|
|
@ -50,7 +50,6 @@ export const paramDef = {
|
||||||
default: null,
|
default: null,
|
||||||
description: 'The local host is represented with `null`.',
|
description: 'The local host is represented with `null`.',
|
||||||
},
|
},
|
||||||
trending: { type: 'boolean', default: false },
|
|
||||||
},
|
},
|
||||||
required: [],
|
required: [],
|
||||||
} as const;
|
} as const;
|
||||||
|
@ -67,12 +66,9 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
) {
|
) {
|
||||||
super(meta, paramDef, async (ps, me) => {
|
super(meta, paramDef, async (ps, me) => {
|
||||||
const query = this.usersRepository.createQueryBuilder('user')
|
const query = this.usersRepository.createQueryBuilder('user')
|
||||||
|
.andWhere('user.isExplorable = TRUE')
|
||||||
.andWhere('user.isSuspended = FALSE');
|
.andWhere('user.isSuspended = FALSE');
|
||||||
|
|
||||||
if (ps.trending) {
|
|
||||||
query.andWhere('user.isExplorable = TRUE');
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (ps.state) {
|
switch (ps.state) {
|
||||||
case 'alive': query.andWhere('user.updatedAt > :date', { date: new Date(Date.now() - 1000 * 60 * 60 * 24 * 5) }); break;
|
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<typeof meta, typeof paramDef> { // eslint-
|
||||||
query.limit(ps.limit);
|
query.limit(ps.limit);
|
||||||
query.offset(ps.offset);
|
query.offset(ps.offset);
|
||||||
|
|
||||||
let users = await query.getMany();
|
const allUsers = await query.getMany();
|
||||||
|
|
||||||
// This is not ideal, for a couple of reasons:
|
// This is not ideal, for a couple of reasons:
|
||||||
// 1. It may return less than "limit" results.
|
// 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.
|
// 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.
|
// 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(allUsers.map(async u => [u, await this.roleService.getUserPolicies(u)] as const));
|
||||||
const usersWithRoles = await Promise.all(users.map(async u => [u, await this.roleService.getUserPolicies(u)] as const));
|
const users = usersWithRoles
|
||||||
users = usersWithRoles
|
.filter(([,p]) => p.canTrend)
|
||||||
.filter(([,p]) => p.canTrend)
|
.map(([u]) => u);
|
||||||
.map(([u]) => u);
|
|
||||||
}
|
|
||||||
|
|
||||||
return await this.userEntityService.packMany(users, me, { schema: 'UserDetailed' });
|
return await this.userEntityService.packMany(users, me, { schema: 'UserDetailed' });
|
||||||
});
|
});
|
||||||
|
|
|
@ -97,7 +97,6 @@ const tagUsers = computed(() => ({
|
||||||
tag: props.tag,
|
tag: props.tag,
|
||||||
origin: 'combined',
|
origin: 'combined',
|
||||||
sort: '+follower',
|
sort: '+follower',
|
||||||
trending: true,
|
|
||||||
},
|
},
|
||||||
} as const));
|
} as const));
|
||||||
|
|
||||||
|
@ -106,40 +105,33 @@ const popularUsers = { endpoint: 'users', limit: 10, noPaging: true, params: {
|
||||||
state: 'alive',
|
state: 'alive',
|
||||||
origin: 'local',
|
origin: 'local',
|
||||||
sort: '+follower',
|
sort: '+follower',
|
||||||
trending: true,
|
|
||||||
} } as const;
|
} } as const;
|
||||||
const recentlyUpdatedUsers = { endpoint: 'users', limit: 10, noPaging: true, params: {
|
const recentlyUpdatedUsers = { endpoint: 'users', limit: 10, noPaging: true, params: {
|
||||||
origin: 'local',
|
origin: 'local',
|
||||||
sort: '+updatedAt',
|
sort: '+updatedAt',
|
||||||
trending: true,
|
|
||||||
} } as const;
|
} } as const;
|
||||||
const recentlyRegisteredUsers = { endpoint: 'users', limit: 10, noPaging: true, params: {
|
const recentlyRegisteredUsers = { endpoint: 'users', limit: 10, noPaging: true, params: {
|
||||||
origin: 'local',
|
origin: 'local',
|
||||||
state: 'alive',
|
state: 'alive',
|
||||||
sort: '+createdAt',
|
sort: '+createdAt',
|
||||||
trending: true,
|
|
||||||
} } as const;
|
} } as const;
|
||||||
const popularUsersF = { endpoint: 'users', limit: 10, noPaging: true, params: {
|
const popularUsersF = { endpoint: 'users', limit: 10, noPaging: true, params: {
|
||||||
state: 'alive',
|
state: 'alive',
|
||||||
origin: 'remote',
|
origin: 'remote',
|
||||||
sort: '+follower',
|
sort: '+follower',
|
||||||
trending: true,
|
|
||||||
} } as const;
|
} } as const;
|
||||||
const popularUsersLocalF = { endpoint: 'users', limit: 10, noPaging: true, params: {
|
const popularUsersLocalF = { endpoint: 'users', limit: 10, noPaging: true, params: {
|
||||||
state: 'alive',
|
state: 'alive',
|
||||||
origin: 'remote',
|
origin: 'remote',
|
||||||
sort: '+localFollower',
|
sort: '+localFollower',
|
||||||
trending: true,
|
|
||||||
} } as const;
|
} } as const;
|
||||||
const recentlyUpdatedUsersF = { endpoint: 'users', limit: 10, noPaging: true, params: {
|
const recentlyUpdatedUsersF = { endpoint: 'users', limit: 10, noPaging: true, params: {
|
||||||
origin: 'combined',
|
origin: 'combined',
|
||||||
sort: '+updatedAt',
|
sort: '+updatedAt',
|
||||||
trending: true,
|
|
||||||
} } as const;
|
} } as const;
|
||||||
const recentlyRegisteredUsersF = { endpoint: 'users', limit: 10, noPaging: true, params: {
|
const recentlyRegisteredUsersF = { endpoint: 'users', limit: 10, noPaging: true, params: {
|
||||||
origin: 'combined',
|
origin: 'combined',
|
||||||
sort: '+createdAt',
|
sort: '+createdAt',
|
||||||
trending: true,
|
|
||||||
} } as const;
|
} } as const;
|
||||||
|
|
||||||
misskeyApi('hashtags/list', {
|
misskeyApi('hashtags/list', {
|
||||||
|
|
|
@ -31541,8 +31541,6 @@ export type operations = {
|
||||||
* @default null
|
* @default null
|
||||||
*/
|
*/
|
||||||
hostname?: string | null;
|
hostname?: string | null;
|
||||||
/** @default false */
|
|
||||||
trending?: boolean;
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue