Skip to content

Commit 93562d0

Browse files
committed
fix(api): remove obsolete validation call in PUT handler
The PUT handler in routes/api/v1/data/[id]/index.dart contained a manual check for user_content_preferences that called the old checkUpdatePreferences method, which has been removed. This caused a compile-time error. This change removes the obsolete if block. The validation logic is now correctly and exclusively handled by the custom updater for user_content_preferences within the DataOperationRegistry, which was implemented in a previous step. This resolves the error and ensures the correct validation path is used.
1 parent 11403f0 commit 93562d0

File tree

1 file changed

+0
-24
lines changed

1 file changed

+0
-24
lines changed

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

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import 'package:flutter_news_app_api_server_full_source_code/src/middlewares/own
77
import 'package:flutter_news_app_api_server_full_source_code/src/rbac/permission_service.dart';
88
import 'package:flutter_news_app_api_server_full_source_code/src/registry/data_operation_registry.dart';
99
import 'package:flutter_news_app_api_server_full_source_code/src/registry/model_registry.dart';
10-
import 'package:flutter_news_app_api_server_full_source_code/src/services/user_preference_limit_service.dart';
1110
import 'package:logging/logging.dart';
1211

1312
// Create a logger for this file.
@@ -57,7 +56,6 @@ Future<Response> _handlePut(RequestContext context, String id) async {
5756
final modelConfig = context.read<ModelConfig<dynamic>>();
5857
final authenticatedUser = context.read<User?>();
5958
final permissionService = context.read<PermissionService>();
60-
final userPreferenceLimitService = context.read<UserPreferenceLimitService>();
6159

6260
_logger.info('Handling PUT request for model "$modelName", id "$id".');
6361

@@ -105,28 +103,6 @@ Future<Response> _handlePut(RequestContext context, String id) async {
105103
}
106104
}
107105

108-
if (modelName == 'user_content_preferences') {
109-
// User content preferences can only be updated by an authenticated user.
110-
if (authenticatedUser == null) {
111-
throw const UnauthorizedException(
112-
'Authentication required to update user content preferences.',
113-
);
114-
}
115-
if (itemToUpdate is UserContentPreferences) {
116-
await userPreferenceLimitService.checkUpdatePreferences(
117-
authenticatedUser,
118-
itemToUpdate,
119-
);
120-
} else {
121-
_logger.severe(
122-
'Type Error: Expected UserContentPreferences for limit check, but got ${itemToUpdate.runtimeType}.',
123-
);
124-
throw const OperationFailedException(
125-
'Internal Server Error: Model type mismatch for limit check.',
126-
);
127-
}
128-
}
129-
130106
final userIdForRepoCall = _getUserIdForRepoCall(
131107
modelConfig: modelConfig,
132108
permissionService: permissionService,

0 commit comments

Comments
 (0)