@@ -21,8 +21,7 @@ Future<Response> onRequest(RequestContext context, String id) async {
21
21
final permissionService =
22
22
context.read <PermissionService >(); // Read PermissionService
23
23
// Read the UserPreferenceLimitService (only needed for UserContentPreferences PUT)
24
- final userPreferenceLimitService =
25
- context.read <UserPreferenceLimitService >();
24
+ final userPreferenceLimitService = context.read <UserPreferenceLimitService >();
26
25
27
26
// The main try/catch block here is removed to let the errorHandler middleware
28
27
// handle all exceptions thrown by the handlers below.
@@ -119,7 +118,10 @@ Future<Response> _handleGet(
119
118
item = await repo.read (id: id, userId: userIdForRepoCall);
120
119
case 'app_config' : // New case for AppConfig (read by admin)
121
120
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
123
125
default :
124
126
// This case should ideally be caught by middleware, but added for safety
125
127
// Throw an exception to be caught by the errorHandler
@@ -186,7 +188,8 @@ Future<Response> _handlePut(
186
188
ModelConfig <dynamic > modelConfig,
187
189
User authenticatedUser,
188
190
PermissionService permissionService, // Receive PermissionService
189
- UserPreferenceLimitService userPreferenceLimitService, // Receive Limit Service
191
+ UserPreferenceLimitService
192
+ userPreferenceLimitService, // Receive Limit Service
190
193
String requestId,
191
194
) async {
192
195
// Authorization check is handled by authorizationMiddleware before this.
@@ -238,11 +241,11 @@ Future<Response> _handlePut(
238
241
try {
239
242
// Ensure the itemToUpdate is the correct type for the limit service
240
243
if (itemToUpdate is ! UserContentPreferences ) {
241
- print (
244
+ print (
242
245
'[ReqID: $requestId ] Type Error: Expected UserContentPreferences '
243
246
'for limit check, but got ${itemToUpdate .runtimeType }.' ,
244
247
);
245
- throw const OperationFailedException (
248
+ throw const OperationFailedException (
246
249
'Internal Server Error: Model type mismatch for limit check.' ,
247
250
);
248
251
}
@@ -259,7 +262,7 @@ Future<Response> _handlePut(
259
262
'[ReqID: $requestId ] Unexpected error during limit check for '
260
263
'UserContentPreferences PUT: $e ' ,
261
264
);
262
- throw OperationFailedException (
265
+ throw const OperationFailedException (
263
266
'An unexpected error occurred during limit check.' ,
264
267
);
265
268
}
@@ -487,7 +490,10 @@ Future<Response> _handleDelete(
487
490
itemToDelete = await repo.read (id: id, userId: userIdForRepoCall);
488
491
case 'app_config' : // New case for AppConfig (delete by admin)
489
492
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
491
497
default :
492
498
print (
493
499
'[ReqID: $requestId ] Error: Unsupported model type "$modelName " reached _handleDelete ownership check.' ,
@@ -545,9 +551,10 @@ Future<Response> _handleDelete(
545
551
.read <HtDataRepository <UserContentPreferences >>()
546
552
.delete (id: id, userId: userIdForRepoCall);
547
553
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
551
558
default :
552
559
// This case should ideally be caught by the data/_middleware.dart,
553
560
// but added for safety. Consider logging this unexpected state.
0 commit comments