mirror of
https://github.com/zkldi/Tachi.git
synced 2026-10-04 12:58:11 +03:00
POST /replays
This commit is contained in:
@@ -23,6 +23,7 @@ import { GetPBOnChart, GetServerRecordOnChart } from "../../../common/scores";
|
||||
import crypto from "crypto";
|
||||
import { Random20Hex } from "../../../common/util";
|
||||
import { USCIR_ADJACENT_SCORE_N, USCIR_MAX_LEADERBOARD_N } from "../../../constants/usc-ir";
|
||||
import { CreateMulterSingleUploadMiddleware } from "../../../common/multer";
|
||||
|
||||
const logger = CreateLogCtx("usc.ts");
|
||||
|
||||
@@ -313,4 +314,39 @@ router.post("/scores", async (req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Used to submit the replay for a given score when requested by the server.
|
||||
* https://uscir.readthedocs.io/en/latest/endpoints/replay-submit.html
|
||||
* @name POST /api/ir/usc/replays
|
||||
*/
|
||||
router.post("/replays", CreateMulterSingleUploadMiddleware("replay"), async (req, res) => {
|
||||
if (typeof req.body.identifier !== "string") {
|
||||
return res.status(200).json({
|
||||
statusCode: STATUS_CODES.BAD_REQ,
|
||||
description: "No Identifier Provided.",
|
||||
});
|
||||
}
|
||||
|
||||
const correspondingScore = await db.scores.findOne({
|
||||
userID: req[SYMBOL_KtchiData]!.uscAuthDoc!.userID,
|
||||
game: "usc",
|
||||
"scoreMeta.replayID": req.body.identifier,
|
||||
});
|
||||
|
||||
if (!correspondingScore) {
|
||||
return res.status(200).json({
|
||||
statusCode: STATUS_CODES.NOT_FOUND,
|
||||
description: "No score corresponds to this identifier.",
|
||||
});
|
||||
}
|
||||
|
||||
// @todo #113 Properly store replays sent with POST /replays.
|
||||
|
||||
return res.status(200).json({
|
||||
statusCode: STATUS_CODES.SUCCESS,
|
||||
description: "Saved replay.",
|
||||
body: null,
|
||||
});
|
||||
});
|
||||
|
||||
export default router;
|
||||
|
||||
Reference in New Issue
Block a user