Skip to content

Commit 9248839

Browse files
committed
refactor(services): renale and expand user expand user preference limit service for ugc
Expands the `UserActionLimitService` interface with new, correctly named methods: `checkEngagementCreationLimit` and `checkReportCreationLimit`. This change correctly frames the limit checks around the primary entities (`Engagement`, `Report`) being created, rather than their sub-components. The `checkEngagementCreationLimit` method now accepts the `Engagement` object to allow for conditional logic based on its content (e.g., presence of a comment).
1 parent c266c97 commit 9248839

File tree

2 files changed

+35
-23
lines changed

2 files changed

+35
-23
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import 'package:core/core.dart';
2+
3+
/// {@template user_action_limit_service}
4+
/// A service responsible for enforcing all user-related limits based on
5+
/// the user's role and the application's remote configuration.
6+
///
7+
/// This service centralizes validation for both static preference counts
8+
/// (e.g., number of saved filters) and transactional, time-windowed actions
9+
/// (e.g., number of engagements or reports per day).
10+
/// {@endtemplate}
11+
abstract class UserActionLimitService {
12+
/// {@macro user_action_limit_service}
13+
const UserActionLimitService();
14+
15+
/// Validates an updated [UserContentPreferences] object against all limits
16+
/// for preference counts (e.g., followed items, saved headlines).
17+
///
18+
/// Throws a [ForbiddenException] if any limit is exceeded.
19+
Future<void> checkUserContentPreferencesLimits({
20+
required User user,
21+
required UserContentPreferences updatedPreferences,
22+
});
23+
24+
/// Validates if a user can create a new [Engagement].
25+
///
26+
/// This method checks against `reactionsPerDay` and, if the engagement
27+
/// contains a comment, also checks against `commentsPerDay`.
28+
Future<void> checkEngagementCreationLimit(
29+
{required User user, required Engagement engagement});
30+
31+
/// Validates if a user can create a new [Report].
32+
///
33+
/// This method checks against the `reportsPerDay` limit.
34+
Future<void> checkReportCreationLimit({required User user});
35+
}

lib/src/services/user_preference_limit_service.dart

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)