mirror of
https://github.com/smogon/pokemon-showdown-loginserver.git
synced 2026-03-21 17:34:38 -05:00
Add replay batch endpoint (#28)
This commit is contained in:
parent
574a2e79fe
commit
9d59f10859
|
|
@ -1025,7 +1025,14 @@ export const actions: { [k: string]: QueryHandler } = {
|
|||
}
|
||||
return { password: pw };
|
||||
},
|
||||
|
||||
async 'replays/batch'(params) {
|
||||
if (!params.ids) {
|
||||
throw new ActionError("Invalid batch replay request, must provide ids");
|
||||
}
|
||||
const ids = params.ids.split(',');
|
||||
if (ids.length > 51) throw new ActionError(`Limit 51 IDs (you have ${ids.length}).`);
|
||||
return Replays.getBatch(ids);
|
||||
},
|
||||
// sent by ps server
|
||||
async 'smogon/validate'(params) {
|
||||
if (this.getIp() !== Config.restartip) {
|
||||
|
|
|
|||
|
|
@ -232,6 +232,9 @@ export const Replays = new class {
|
|||
SQL`uploadtime, id, format, players, rating`
|
||||
)`WHERE private = 0 ORDER BY uploadtime DESC LIMIT 51`.then(this.toReplays);
|
||||
}
|
||||
getBatch(ids: string[]) {
|
||||
return replays.selectAll()`WHERE private = 0 AND id IN (${ids}) LIMIT 51`.then(this.toReplays);
|
||||
}
|
||||
};
|
||||
|
||||
export default Replays;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user