fix: queryとbirthdayを同時に受け付けないように

This commit is contained in:
kakkokari-gtyih 2025-12-17 13:24:07 +09:00
parent 999d965715
commit 143296afed
2 changed files with 19 additions and 6 deletions

View File

@ -88,10 +88,21 @@ export const paramDef = {
sinceDate: { type: 'integer' },
untilDate: { type: 'integer' },
limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
birthday: { ...birthdaySchema, nullable: true },
query: { type: 'string', nullable: true },
},
},
{
oneOf: [{
type: 'object',
properties: {
query: { type: 'string' },
},
}, {
type: 'object',
properties: {
birthday: { ...birthdaySchema, nullable: true },
},
}],
},
],
} as const;
@ -151,7 +162,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
.innerJoinAndSelect('following.followee', 'followee');
// query takes priority over birthday
if (ps.query) {
if ('query' in ps && ps.query != null) {
const searchQuery = ps.query;
const isUsername = searchQuery.startsWith('@') && !searchQuery.includes(' ') && searchQuery.indexOf('@', 1) === -1;
@ -164,7 +175,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
qb.orWhere('followee.usernameLower LIKE :username', { username: '%' + sqlLikeEscape(searchQuery.toLowerCase()) + '%' });
}
}));
} else if (ps.birthday) {
} else if ('birthday' in ps && ps.birthday != null) {
try {
const birthday = ps.birthday.substring(5, 10);
const birthdayUserQuery = this.userProfilesRepository.createQueryBuilder('user_profile');

View File

@ -34848,9 +34848,11 @@ export interface operations {
untilDate?: number;
/** @default 10 */
limit?: number;
} & ({
query?: string;
} | {
birthday?: string | null;
query?: string | null;
};
});
};
};
responses: {