Skip to content

Commit 01b34e3

Browse files
committed
feat(data): add app_review data operations
- Register read and readAll operations for AppReview - Implement custom create operation with security check for AppReview - Add update and delete operations for AppReview
1 parent ac77c04 commit 01b34e3

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

lib/src/registry/data_operation_registry.dart

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ class DataOperationRegistry {
132132
c.read<DataRepository<Engagement>>().read(id: id, userId: null),
133133
'report': (c, id) =>
134134
c.read<DataRepository<Report>>().read(id: id, userId: null),
135+
'app_review': (c, id) =>
136+
c.read<DataRepository<AppReview>>().read(id: id, userId: null),
135137
});
136138

137139
// --- Register "Read All" Readers ---
@@ -208,6 +210,13 @@ class DataOperationRegistry {
208210
sort: s,
209211
pagination: p,
210212
),
213+
'app_review': (c, uid, f, s, p) =>
214+
c.read<DataRepository<AppReview>>().readAll(
215+
userId: uid,
216+
filter: f,
217+
sort: s,
218+
pagination: p,
219+
),
211220
});
212221

213222
// --- Register Item Creators ---
@@ -340,6 +349,21 @@ class DataOperationRegistry {
340349

341350
return context.read<DataRepository<Report>>().create(item: item);
342351
},
352+
'app_review': (context, item, uid) async {
353+
_log.info('Executing custom creator for app_review.');
354+
final authenticatedUser = context.read<User>();
355+
final userActionLimitService = context.read<UserActionLimitService>();
356+
final appReviewToCreate = item as AppReview;
357+
358+
// Security Check
359+
if (appReviewToCreate.userId != authenticatedUser.id) {
360+
throw const ForbiddenException(
361+
'You can only create app reviews for your own account.',
362+
);
363+
}
364+
365+
return context.read<DataRepository<AppReview>>().create(item: item);
366+
},
343367
});
344368

345369
// --- Register Item Updaters ---
@@ -509,6 +533,11 @@ class DataOperationRegistry {
509533
id: id,
510534
item: item as Report,
511535
),
536+
'app_review': (c, id, item, uid) =>
537+
c.read<DataRepository<AppReview>>().update(
538+
id: id,
539+
item: item as AppReview,
540+
),
512541
});
513542

514543
// --- Register Item Deleters ---
@@ -540,6 +569,8 @@ class DataOperationRegistry {
540569
c.read<DataRepository<Engagement>>().delete(id: id, userId: uid),
541570
'report': (c, id, uid) =>
542571
c.read<DataRepository<Report>>().delete(id: id, userId: uid),
572+
'app_review': (c, id, uid) =>
573+
c.read<DataRepository<AppReview>>().delete(id: id, userId: uid),
543574
});
544575
}
545576
}

0 commit comments

Comments
 (0)