From c7966bb81dc016fed14fbdf32d31fe4c89b61a6c Mon Sep 17 00:00:00 2001 From: winter Date: Mon, 9 Jan 2023 21:48:07 +0900 Subject: [PATCH] rateable levels --- src/endpoints/levels/rateLevel.cr | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/endpoints/levels/rateLevel.cr b/src/endpoints/levels/rateLevel.cr index 4bc6670..4f06da3 100644 --- a/src/endpoints/levels/rateLevel.cr +++ b/src/endpoints/levels/rateLevel.cr @@ -93,3 +93,21 @@ CrystalGauntlet.endpoints["/rateGJLevel.php"] = ->(context : HTTP::Server::Conte "-1" } +CrystalGauntlet.endpoints["/suggestGJStars20.php"] = ->(context : HTTP::Server::Context) : String { + params = URI::Params.parse(context.request.body.not_nil!.gets_to_end) + LOG.debug { params.inspect } + + user_id, account_id = Accounts.auth(params) + if !(user_id && account_id) + return "-1" + end + + rank = Ranks.get_rank(account_id) + if !Ranks.has_permission(rank, "rate_levels") + return "-2" + end + + DATABASE.exec "update levels set stars = ?, featured = ?, difficulty = ? where id = ?", params["stars"].to_i, params["feature"].to_i, (stars_to_difficulty(params["stars"].to_i) || LevelDifficulty::Easy).to_i, params["levelID"].to_i + "1" +} +