Skip to content

Commit 712ce1c

Browse files
committed
Don't block level queueing/overriding if read-only
1 parent 2442654 commit 712ce1c

3 files changed

Lines changed: 11 additions & 35 deletions

File tree

Refresh.Interfaces.APIv3/Endpoints/LevelApiEndpoints.cs

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,8 @@ public ApiOkResponse SetLevelAsOverrideById(RequestContext context,
119119
GameDatabaseContext database,
120120
GameUser user,
121121
PlayNowService overrideService,
122-
[DocSummary("The ID of the level")] int id, GameServerConfig config)
122+
[DocSummary("The ID of the level")] int id)
123123
{
124-
if (user.IsWriteBlocked(config))
125-
return ApiAuthenticationError.ReadOnlyError;
126-
127124
GameLevel? level = database.GetLevelById(id);
128125
if (level == null) return ApiNotFoundError.LevelMissingError;
129126

@@ -139,11 +136,8 @@ public ApiOkResponse SetLevelAsOverrideById(RequestContext context,
139136
[RateLimitSettings(LevelOverrideEndpointLimits.TimeoutDuration, LevelOverrideEndpointLimits.RequestAmount,
140137
LevelOverrideEndpointLimits.BlockDuration, LevelOverrideEndpointLimits.RequestBucket)]
141138
public ApiOkResponse SetLevelAsOverrideByHash(RequestContext context, GameDatabaseContext database, GameUser user,
142-
PlayNowService service, PresenceService presenceService, [DocSummary("The hash of level root resource")] string hash, GameServerConfig config)
139+
PlayNowService service, PresenceService presenceService, [DocSummary("The hash of level root resource")] string hash)
143140
{
144-
if (user.IsWriteBlocked(config))
145-
return ApiAuthenticationError.ReadOnlyError;
146-
147141
if (!CommonPatterns.Sha1Regex().IsMatch(hash))
148142
return ApiValidationError.HashInvalidError;
149143

@@ -172,7 +166,7 @@ public ApiResponse<ApiGameLevelOwnRelationsResponse> GetLevelRelationsOfUser(Req
172166
[DocError(typeof(ApiNotFoundError), ApiNotFoundError.LevelMissingErrorWhen)]
173167
[RateLimitSettings(CommonRelationEndpointLimits.TimeoutDuration, CommonRelationEndpointLimits.RequestAmount,
174168
CommonRelationEndpointLimits.BlockDuration, CommonRelationEndpointLimits.RequestBucket)]
175-
public ApiOkResponse FavouriteLevel(RequestContext context, GameDatabaseContext database, GameUser user,
169+
public ApiOkResponse HeartLevel(RequestContext context, GameDatabaseContext database, GameUser user,
176170
[DocSummary("The ID of the level")] int id, DataContext dataContext, GameServerConfig config)
177171
{
178172
if (user.IsWriteBlocked(config))
@@ -211,11 +205,8 @@ public ApiOkResponse UnheartLevel(RequestContext context, GameDatabaseContext da
211205
[RateLimitSettings(CommonRelationEndpointLimits.TimeoutDuration, CommonRelationEndpointLimits.RequestAmount,
212206
CommonRelationEndpointLimits.BlockDuration, CommonRelationEndpointLimits.RequestBucket)]
213207
public ApiOkResponse QueueLevel(RequestContext context, GameDatabaseContext database, GameUser user,
214-
[DocSummary("The ID of the level")] int id, DataContext dataContext, GameServerConfig config)
208+
[DocSummary("The ID of the level")] int id, DataContext dataContext)
215209
{
216-
if (user.IsWriteBlocked(config))
217-
return ApiAuthenticationError.ReadOnlyError;
218-
219210
GameLevel? level = database.GetLevelById(id);
220211
if (level == null) return ApiNotFoundError.LevelMissingError;
221212

@@ -236,11 +227,8 @@ public ApiOkResponse QueueLevel(RequestContext context, GameDatabaseContext data
236227
[RateLimitSettings(CommonRelationEndpointLimits.TimeoutDuration, CommonRelationEndpointLimits.RequestAmount,
237228
CommonRelationEndpointLimits.BlockDuration, CommonRelationEndpointLimits.RequestBucket)]
238229
public ApiOkResponse DequeueLevel(RequestContext context, GameDatabaseContext database, GameUser user,
239-
[DocSummary("The ID of the level")] int id, DataContext dataContext, GameServerConfig config)
230+
[DocSummary("The ID of the level")] int id, DataContext dataContext)
240231
{
241-
if (user.IsWriteBlocked(config))
242-
return ApiAuthenticationError.ReadOnlyError;
243-
244232
GameLevel? level = database.GetLevelById(id);
245233
if (level == null) return ApiNotFoundError.LevelMissingError;
246234

@@ -254,11 +242,8 @@ public ApiOkResponse DequeueLevel(RequestContext context, GameDatabaseContext da
254242
[RateLimitSettings(CommonRelationEndpointLimits.TimeoutDuration, CommonRelationEndpointLimits.RequestAmount,
255243
CommonRelationEndpointLimits.BlockDuration, CommonRelationEndpointLimits.RequestBucket)]
256244
public ApiOkResponse ClearQueuedLevels(RequestContext context, GameDatabaseContext database,
257-
IDataStore dataStore, GameUser user, DataContext dataContext, GameServerConfig config)
245+
GameUser user, DataContext dataContext)
258246
{
259-
if (user.IsWriteBlocked(config))
260-
return ApiAuthenticationError.ReadOnlyError;
261-
262247
database.ClearQueue(user);
263248
dataContext.Cache.ClearQueueByUser(user);
264249
return new ApiOkResponse();

Refresh.Interfaces.Game/Endpoints/RelationEndpoints.cs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,8 @@ public Response UnfavouriteUser(RequestContext context, GameDatabaseContext data
120120
[RequireEmailVerified]
121121
[RateLimitSettings(CommonRelationEndpointLimits.TimeoutDuration, CommonRelationEndpointLimits.RequestAmount,
122122
CommonRelationEndpointLimits.BlockDuration, CommonRelationEndpointLimits.RequestBucket)]
123-
public Response QueueLevel(RequestContext context, GameDatabaseContext database, GameUser user, string slotType, int id, DataContext dataContext, GameServerConfig config)
123+
public Response QueueLevel(RequestContext context, GameDatabaseContext database, GameUser user, string slotType, int id, DataContext dataContext)
124124
{
125-
if (user.IsWriteBlocked(config))
126-
return Unauthorized;
127-
128125
GameLevel? level = database.GetLevelByIdAndType(slotType, id);
129126
if (level == null) return NotFound;
130127

@@ -137,11 +134,8 @@ public Response QueueLevel(RequestContext context, GameDatabaseContext database,
137134
[RequireEmailVerified]
138135
[RateLimitSettings(CommonRelationEndpointLimits.TimeoutDuration, CommonRelationEndpointLimits.RequestAmount,
139136
CommonRelationEndpointLimits.BlockDuration, CommonRelationEndpointLimits.RequestBucket)]
140-
public Response DequeueLevel(RequestContext context, GameDatabaseContext database, GameUser user, string slotType, int id, DataContext dataContext, GameServerConfig config)
137+
public Response DequeueLevel(RequestContext context, GameDatabaseContext database, GameUser user, string slotType, int id, DataContext dataContext)
141138
{
142-
if (user.IsWriteBlocked(config))
143-
return Unauthorized;
144-
145139
GameLevel? level = database.GetLevelByIdAndType(slotType, id);
146140
if (level == null) return NotFound;
147141

@@ -154,11 +148,8 @@ public Response DequeueLevel(RequestContext context, GameDatabaseContext databas
154148
[RequireEmailVerified]
155149
[RateLimitSettings(CommonRelationEndpointLimits.TimeoutDuration, CommonRelationEndpointLimits.RequestAmount,
156150
CommonRelationEndpointLimits.BlockDuration, CommonRelationEndpointLimits.RequestBucket)]
157-
public Response ClearQueue(RequestContext context, GameDatabaseContext database, GameUser user, DataContext dataContext, GameServerConfig config)
151+
public Response ClearQueue(RequestContext context, GameDatabaseContext database, GameUser user, DataContext dataContext)
158152
{
159-
if (user.IsWriteBlocked(config))
160-
return Unauthorized;
161-
162153
database.ClearQueue(user);
163154
dataContext.Cache.ClearQueueByUser(user);
164155
return OK;

Refresh.Interfaces.Game/Endpoints/UserEndpoints.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,14 +213,14 @@ public SerializedFriendsList GetFriends(RequestContext context, GameDatabaseCont
213213

214214
// Return newly updated pins (LBP2 and 3 update their pin progresses if there are higher progress values
215215
// in the response, but seemingly ignore the profile pins in the response)
216-
return this.GetPins(context, dataContext, user, config);
216+
return this.GetPins(context, dataContext, user);
217217
}
218218

219219
[GameEndpoint("get_my_pins", HttpMethods.Get, ContentType.Json)]
220220
[MinimumRole(GameUserRole.Restricted)]
221221
[NullStatusCode(Unauthorized)]
222222
[RateLimitSettings(PinTimeoutDuration, PinRequestAmount, PinBlockDuration, PinBucket)]
223-
public SerializedPins? GetPins(RequestContext context, DataContext dataContext, GameUser user, GameServerConfig config)
223+
public SerializedPins? GetPins(RequestContext context, DataContext dataContext, GameUser user)
224224
{
225225
return SerializedPins.FromOld
226226
(

0 commit comments

Comments
 (0)