fix: queryとbirthdayを同時に受け付けないように
This commit is contained in:
parent
999d965715
commit
143296afed
|
|
@ -88,10 +88,21 @@ export const paramDef = {
|
||||||
sinceDate: { type: 'integer' },
|
sinceDate: { type: 'integer' },
|
||||||
untilDate: { type: 'integer' },
|
untilDate: { type: 'integer' },
|
||||||
limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
|
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;
|
} as const;
|
||||||
|
|
||||||
|
|
@ -151,7 +162,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
.innerJoinAndSelect('following.followee', 'followee');
|
.innerJoinAndSelect('following.followee', 'followee');
|
||||||
|
|
||||||
// query takes priority over birthday
|
// query takes priority over birthday
|
||||||
if (ps.query) {
|
if ('query' in ps && ps.query != null) {
|
||||||
const searchQuery = ps.query;
|
const searchQuery = ps.query;
|
||||||
const isUsername = searchQuery.startsWith('@') && !searchQuery.includes(' ') && searchQuery.indexOf('@', 1) === -1;
|
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()) + '%' });
|
qb.orWhere('followee.usernameLower LIKE :username', { username: '%' + sqlLikeEscape(searchQuery.toLowerCase()) + '%' });
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
} else if (ps.birthday) {
|
} else if ('birthday' in ps && ps.birthday != null) {
|
||||||
try {
|
try {
|
||||||
const birthday = ps.birthday.substring(5, 10);
|
const birthday = ps.birthday.substring(5, 10);
|
||||||
const birthdayUserQuery = this.userProfilesRepository.createQueryBuilder('user_profile');
|
const birthdayUserQuery = this.userProfilesRepository.createQueryBuilder('user_profile');
|
||||||
|
|
|
||||||
|
|
@ -34848,9 +34848,11 @@ export interface operations {
|
||||||
untilDate?: number;
|
untilDate?: number;
|
||||||
/** @default 10 */
|
/** @default 10 */
|
||||||
limit?: number;
|
limit?: number;
|
||||||
|
} & ({
|
||||||
|
query?: string;
|
||||||
|
} | {
|
||||||
birthday?: string | null;
|
birthday?: string | null;
|
||||||
query?: string | null;
|
});
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
responses: {
|
responses: {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue