Skip to content

Commit

Permalink
On PSP, dont return NotFound for favourite endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
Beyley committed Oct 3, 2023
1 parent ae8094e commit 9434804
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions Refresh.GameServer/Endpoints/Game/RelationEndpoints.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,55 +20,59 @@ 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;
}

[GameEndpoint("unfavourite/slot/user/{id}", HttpMethods.Post)]
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;
}

[GameEndpoint("favourite/user/{username}", HttpMethods.Post)]
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;
}

[GameEndpoint("unfavourite/user/{username}", HttpMethods.Post)]
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;
}

Expand Down

0 comments on commit 9434804

Please sign in to comment.