summaryrefslogtreecommitdiff
path: root/packages/backend/src/server/api/endpoints/users/followers.ts
diff options
context:
space:
mode:
authorzyoshoka <107108195+zyoshoka@users.noreply.github.com>2025-05-27 08:57:09 +0900
committerGitHub <noreply@github.com>2025-05-27 08:57:09 +0900
commitd27075c5f536a86a6c81cb3c3cec92b302663e2e (patch)
treec9ab17782c4bc77da1f534c8731bbad5a0000849 /packages/backend/src/server/api/endpoints/users/followers.ts
parentfix(backend): add response schema for `notes/show-partial-bulk` endpoint (#16... (diff)
downloadmisskey-d27075c5f536a86a6c81cb3c3cec92b302663e2e.tar.gz
misskey-d27075c5f536a86a6c81cb3c3cec92b302663e2e.tar.bz2
misskey-d27075c5f536a86a6c81cb3c3cec92b302663e2e.zip
fix(backend): correct invalid schema format specifying only `required` for `anyOf` (#16089)
* fix(backend): correct invalid schema format specifying only `required` for `anyOf` * refactor(backend): make types derived from `allOf` or `anyOf` more strong
Diffstat (limited to 'packages/backend/src/server/api/endpoints/users/followers.ts')
-rw-r--r--packages/backend/src/server/api/endpoints/users/followers.ts51
1 files changed, 33 insertions, 18 deletions
diff --git a/packages/backend/src/server/api/endpoints/users/followers.ts b/packages/backend/src/server/api/endpoints/users/followers.ts
index a8b4319a61..bb8d4c49e9 100644
--- a/packages/backend/src/server/api/endpoints/users/followers.ts
+++ b/packages/backend/src/server/api/endpoints/users/followers.ts
@@ -47,23 +47,38 @@ export const meta = {
} as const;
export const paramDef = {
- type: 'object',
- properties: {
- sinceId: { type: 'string', format: 'misskey:id' },
- untilId: { type: 'string', format: 'misskey:id' },
- limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
-
- userId: { type: 'string', format: 'misskey:id' },
- username: { type: 'string' },
- host: {
- type: 'string',
- nullable: true,
- description: 'The local host is represented with `null`.',
+ allOf: [
+ {
+ anyOf: [
+ {
+ type: 'object',
+ properties: {
+ userId: { type: 'string', format: 'misskey:id' },
+ },
+ required: ['userId'],
+ },
+ {
+ type: 'object',
+ properties: {
+ username: { type: 'string' },
+ host: {
+ type: 'string',
+ nullable: true,
+ description: 'The local host is represented with `null`.',
+ },
+ },
+ required: ['username', 'host'],
+ },
+ ],
+ },
+ {
+ type: 'object',
+ properties: {
+ sinceId: { type: 'string', format: 'misskey:id' },
+ untilId: { type: 'string', format: 'misskey:id' },
+ limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
+ },
},
- },
- anyOf: [
- { required: ['userId'] },
- { required: ['username', 'host'] },
],
} as const;
@@ -85,9 +100,9 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
private roleService: RoleService,
) {
super(meta, paramDef, async (ps, me) => {
- const user = await this.usersRepository.findOneBy(ps.userId != null
+ const user = await this.usersRepository.findOneBy('userId' in ps
? { id: ps.userId }
- : { usernameLower: ps.username!.toLowerCase(), host: this.utilityService.toPunyNullable(ps.host) ?? IsNull() });
+ : { usernameLower: ps.username.toLowerCase(), host: this.utilityService.toPunyNullable(ps.host) ?? IsNull() });
if (user == null) {
throw new ApiError(meta.errors.noSuchUser);