@@ -27,7 +27,7 @@ public class ReviewEndpoints : EndpointGroup
2727 [ RateLimitSettings ( CommonRelationEndpointLimits . TimeoutDuration , CommonRelationEndpointLimits . RequestAmount ,
2828 CommonRelationEndpointLimits . BlockDuration , CommonRelationEndpointLimits . RequestBucket ) ]
2929 public Response SubmitRating ( RequestContext context , GameDatabaseContext database , GameUser user , string slotType ,
30- int id , GameServerConfig config )
30+ int id , GameServerConfig config , DataContext dataContext )
3131 {
3232 if ( user . IsWriteBlocked ( config ) )
3333 return Unauthorized ;
@@ -47,6 +47,8 @@ public Response SubmitRating(RequestContext context, GameDatabaseContext databas
4747 if ( rating is > 1 or < - 1 ) return BadRequest ;
4848
4949 bool rated = database . RateLevel ( level , user , ( RatingType ) rating ) ;
50+ dataContext . Cache . UpdateLevelRatingByUser ( user , level , rating , database ) ;
51+
5052 return rated ? OK : Unauthorized ;
5153 }
5254
@@ -55,7 +57,8 @@ public Response SubmitRating(RequestContext context, GameDatabaseContext databas
5557 [ RequireEmailVerified ]
5658 [ RateLimitSettings ( CommonRelationEndpointLimits . TimeoutDuration , CommonRelationEndpointLimits . RequestAmount ,
5759 CommonRelationEndpointLimits . BlockDuration , CommonRelationEndpointLimits . RequestBucket ) ]
58- public Response RateUserLevel ( RequestContext context , GameDatabaseContext database , GameUser user , string slotType , int id )
60+ public Response RateUserLevel ( RequestContext context , GameDatabaseContext database , GameUser user , string slotType , int id ,
61+ DataContext dataContext )
5962 {
6063 GameLevel ? level = database . GetLevelByIdAndType ( slotType , id ) ;
6164 if ( level == null ) return NotFound ;
@@ -87,7 +90,9 @@ public Response RateUserLevel(RequestContext context, GameDatabaseContext databa
8790 return BadRequest ;
8891 }
8992
90- return database . RateLevel ( level , user , rating ) ? OK : Unauthorized ;
93+ database . RateLevel ( level , user , rating ) ;
94+ dataContext . Cache . UpdateLevelRatingByUser ( user , level , ( int ) rating , database ) ;
95+ return OK ;
9196 }
9297
9398 [ GameEndpoint ( "reviewsFor/{slotType}/{id}" , ContentType . Xml ) ]
@@ -179,6 +184,7 @@ public Response PostReviewForLevel(RequestContext context,
179184 // Update the user's rating if valid
180185 if ( body . Thumb is > 1 or < - 1 ) return BadRequest ;
181186 database . RateLevel ( level , user , ( RatingType ) body . Thumb ) ;
187+ dataContext . Cache . UpdateLevelRatingByUser ( user , level , body . Thumb , database ) ;
182188
183189 // Return the review
184190 return new Response ( SerializedGameReview . FromOld ( review , dataContext ) , ContentType . Xml ) ;
0 commit comments