@@ -21,8 +21,7 @@ Future<Response> onRequest(RequestContext context, String id) async {
2121 final permissionService =
2222 context.read <PermissionService >(); // Read PermissionService
2323 // Read the UserPreferenceLimitService (only needed for UserContentPreferences PUT)
24- final userPreferenceLimitService =
25- context.read <UserPreferenceLimitService >();
24+ final userPreferenceLimitService = context.read <UserPreferenceLimitService >();
2625
2726 // The main try/catch block here is removed to let the errorHandler middleware
2827 // handle all exceptions thrown by the handlers below.
@@ -119,7 +118,10 @@ Future<Response> _handleGet(
119118 item = await repo.read (id: id, userId: userIdForRepoCall);
120119 case 'app_config' : // New case for AppConfig (read by admin)
121120 final repo = context.read <HtDataRepository <AppConfig >>();
122- item = await repo.read (id: id, userId: userIdForRepoCall); // userId should be null for AppConfig
121+ item = await repo.read (
122+ id: id,
123+ userId: userIdForRepoCall,
124+ ); // userId should be null for AppConfig
123125 default :
124126 // This case should ideally be caught by middleware, but added for safety
125127 // Throw an exception to be caught by the errorHandler
@@ -186,7 +188,8 @@ Future<Response> _handlePut(
186188 ModelConfig <dynamic > modelConfig,
187189 User authenticatedUser,
188190 PermissionService permissionService, // Receive PermissionService
189- UserPreferenceLimitService userPreferenceLimitService, // Receive Limit Service
191+ UserPreferenceLimitService
192+ userPreferenceLimitService, // Receive Limit Service
190193 String requestId,
191194) async {
192195 // Authorization check is handled by authorizationMiddleware before this.
@@ -238,11 +241,11 @@ Future<Response> _handlePut(
238241 try {
239242 // Ensure the itemToUpdate is the correct type for the limit service
240243 if (itemToUpdate is ! UserContentPreferences ) {
241- print (
244+ print (
242245 '[ReqID: $requestId ] Type Error: Expected UserContentPreferences '
243246 'for limit check, but got ${itemToUpdate .runtimeType }.' ,
244247 );
245- throw const OperationFailedException (
248+ throw const OperationFailedException (
246249 'Internal Server Error: Model type mismatch for limit check.' ,
247250 );
248251 }
@@ -259,7 +262,7 @@ Future<Response> _handlePut(
259262 '[ReqID: $requestId ] Unexpected error during limit check for '
260263 'UserContentPreferences PUT: $e ' ,
261264 );
262- throw OperationFailedException (
265+ throw const OperationFailedException (
263266 'An unexpected error occurred during limit check.' ,
264267 );
265268 }
@@ -487,7 +490,10 @@ Future<Response> _handleDelete(
487490 itemToDelete = await repo.read (id: id, userId: userIdForRepoCall);
488491 case 'app_config' : // New case for AppConfig (delete by admin)
489492 final repo = context.read <HtDataRepository <AppConfig >>();
490- itemToDelete = await repo.read (id: id, userId: userIdForRepoCall); // userId should be null for AppConfig
493+ itemToDelete = await repo.read (
494+ id: id,
495+ userId: userIdForRepoCall,
496+ ); // userId should be null for AppConfig
491497 default :
492498 print (
493499 '[ReqID: $requestId ] Error: Unsupported model type "$modelName " reached _handleDelete ownership check.' ,
@@ -545,9 +551,10 @@ Future<Response> _handleDelete(
545551 .read <HtDataRepository <UserContentPreferences >>()
546552 .delete (id: id, userId: userIdForRepoCall);
547553 case 'app_config' : // New case for AppConfig (delete by admin)
548- await context
549- .read <HtDataRepository <AppConfig >>()
550- .delete (id: id, userId: userIdForRepoCall); // userId should be null for AppConfig
554+ await context.read <HtDataRepository <AppConfig >>().delete (
555+ id: id,
556+ userId: userIdForRepoCall,
557+ ); // userId should be null for AppConfig
551558 default :
552559 // This case should ideally be caught by the data/_middleware.dart,
553560 // but added for safety. Consider logging this unexpected state.
0 commit comments