From 9434804de89053e83bb2f4d1d47dd257016a0ca3 Mon Sep 17 00:00:00 2001 From: Beyley Thomas Date: Mon, 2 Oct 2023 18:37:14 -0700 Subject: [PATCH] On PSP, dont return NotFound for favourite endpoints --- .../Endpoints/Game/RelationEndpoints.cs | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/Refresh.GameServer/Endpoints/Game/RelationEndpoints.cs b/Refresh.GameServer/Endpoints/Game/RelationEndpoints.cs index 7bc690f4..c2b2ca3d 100644 --- a/Refresh.GameServer/Endpoints/Game/RelationEndpoints.cs +++ b/Refresh.GameServer/Endpoints/Game/RelationEndpoints.cs @@ -20,13 +20,14 @@ public class RelationEndpoints : EndpointGroup public Response FavouriteLevel(RequestContext context, GameDatabaseContext database, GameUser user, int id) { GameLevel? level = database.GetLevelById(id); - if (level == null) return NotFound; + // On PSP, we have to lie or else the client will begin spamming the server + // https://discord.com/channels/1049223665243389953/1049225857350254632/1153468991675838474 + if (level == null) return context.IsPSP() ? OK : NotFound; if (database.FavouriteLevel(level, user)) return OK; - // On PSP, we have to lie or else the client will begin spamming the server - // https://discord.com/channels/1049223665243389953/1049225857350254632/1153468991675838474 + // See above comment about PSP return context.IsPSP() ? OK : Unauthorized; } @@ -34,13 +35,14 @@ public Response FavouriteLevel(RequestContext context, GameDatabaseContext datab public Response UnfavouriteLevel(RequestContext context, GameDatabaseContext database, GameUser user, int id) { GameLevel? level = database.GetLevelById(id); - if (level == null) return NotFound; + // On PSP, we have to lie or else the client will begin spamming the server + // https://discord.com/channels/1049223665243389953/1049225857350254632/1153468991675838474 + if (level == null) return context.IsPSP() ? OK : NotFound; if (database.UnfavouriteLevel(level, user)) return OK; - // On PSP, we have to lie or else the client will begin spamming the server - // https://discord.com/channels/1049223665243389953/1049225857350254632/1153468991675838474 + // See above comment about PSP return context.IsPSP() ? OK : Unauthorized; } @@ -48,13 +50,14 @@ public Response UnfavouriteLevel(RequestContext context, GameDatabaseContext dat public Response FavouriteUser(RequestContext context, GameDatabaseContext database, GameUser user, string username) { GameUser? userToFavourite = database.GetUserByUsername(username); - if (userToFavourite == null) return NotFound; + // On PSP, we have to lie or else the client will begin spamming the server + // https://discord.com/channels/1049223665243389953/1049225857350254632/1153468991675838474 + if (userToFavourite == null) return context.IsPSP() ? OK : NotFound; if (database.FavouriteUser(userToFavourite, user)) return OK; - // On PSP, we have to lie or else the client will begin spamming the server - // https://discord.com/channels/1049223665243389953/1049225857350254632/1153468991675838474 + // See above comment about PSP return context.IsPSP() ? OK : Unauthorized; } @@ -62,13 +65,14 @@ public Response FavouriteUser(RequestContext context, GameDatabaseContext databa public Response UnfavouriteUser(RequestContext context, GameDatabaseContext database, GameUser user, string username) { GameUser? userToFavourite = database.GetUserByUsername(username); - if (userToFavourite == null) return NotFound; + // On PSP, we have to lie or else the client will begin spamming the server + // https://discord.com/channels/1049223665243389953/1049225857350254632/1153468991675838474 + if (userToFavourite == null) return context.IsPSP() ? OK : NotFound; if (database.UnfavouriteUser(userToFavourite, user)) return OK; - // On PSP, we have to lie or else the client will begin spamming the server - // https://discord.com/channels/1049223665243389953/1049225857350254632/1153468991675838474 + // See above comment about PSP return context.IsPSP() ? OK : Unauthorized; }