Skip to content

Commit 15086e4

Browse files
committed
style: misc
1 parent 2fe023b commit 15086e4

File tree

3 files changed

+21
-14
lines changed

3 files changed

+21
-14
lines changed

lib/src/services/default_user_preference_limit_service.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class DefaultUserPreferenceLimitService implements UserPreferenceLimitService {
1717

1818
final HtDataRepository<AppConfig> _appConfigRepository;
1919
final HtDataRepository<UserContentPreferences>
20+
// ignore: unused_field
2021
_userContentPreferencesRepository;
2122

2223
// Assuming a fixed ID for the AppConfig document
@@ -77,7 +78,7 @@ class DefaultUserPreferenceLimitService implements UserPreferenceLimitService {
7778
print(
7879
'Error checking limit for user ${user.id}, itemType $itemType: $e',
7980
);
80-
throw OperationFailedException(
81+
throw const OperationFailedException(
8182
'Failed to check user preference limits.',
8283
);
8384
}
@@ -146,7 +147,7 @@ class DefaultUserPreferenceLimitService implements UserPreferenceLimitService {
146147
print(
147148
'Error checking update limits for user ${user.id}: $e',
148149
);
149-
throw OperationFailedException(
150+
throw const OperationFailedException(
150151
'Failed to check user preference update limits.',
151152
);
152153
}

routes/_middleware.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import 'package:ht_email_repository/ht_email_repository.dart';
2121
import 'package:ht_shared/ht_shared.dart';
2222
import 'package:uuid/uuid.dart';
2323

24-
2524
// --- Request ID Wrapper ---
2625

2726
/// {@template request_id}

routes/api/v1/data/[id].dart

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)