Skip to content

Commit ffda930

Browse files
authored
Dont validate moderate user (#8627)
1 parent b9a746a commit ffda930

File tree

7 files changed

+7
-57
lines changed

7 files changed

+7
-57
lines changed

app/lib/admin/actions/moderate_package.dart

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,7 @@ Note: the action may take a longer time to complete as the public archive bucket
5252
final note = options['note'];
5353

5454
final refCase =
55-
await adminBackend.loadAndVerifyModerationCaseForAdminAction(
56-
caseId,
57-
status: ModerationStatus.pending,
58-
);
55+
await adminBackend.loadAndVerifyModerationCaseForAdminAction(caseId);
5956

6057
final p = await packageBackend.lookupPackage(package!);
6158
if (p == null) {

app/lib/admin/actions/moderate_package_versions.dart

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,7 @@ Set the moderated flag on a package version (updating the flag and the timestamp
6262
final note = options['note'];
6363

6464
final refCase =
65-
await adminBackend.loadAndVerifyModerationCaseForAdminAction(
66-
caseId,
67-
status: ModerationStatus.pending,
68-
);
65+
await adminBackend.loadAndVerifyModerationCaseForAdminAction(caseId);
6966

7067
final p = await packageBackend.lookupPackage(package!);
7168
if (p == null) {

app/lib/admin/actions/moderate_publisher.dart

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,7 @@ can't be updated, administrators must not be able to update publisher options.
5454
final note = options['note'];
5555

5656
final refCase =
57-
await adminBackend.loadAndVerifyModerationCaseForAdminAction(
58-
caseId,
59-
status: ModerationStatus.pending,
60-
);
57+
await adminBackend.loadAndVerifyModerationCaseForAdminAction(caseId);
6158

6259
Publisher? publisher2;
6360
if (valueToSet != null) {

app/lib/admin/actions/moderate_user.dart

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import '../../publisher/backend.dart';
1313
import '../../shared/datastore.dart';
1414

1515
import '../backend.dart';
16-
import '../models.dart';
1716

1817
import 'actions.dart';
1918

@@ -49,10 +48,7 @@ The active web sessions of the user will be expired.
4948
final note = options['note'];
5049

5150
final refCase =
52-
await adminBackend.loadAndVerifyModerationCaseForAdminAction(
53-
caseId,
54-
status: ModerationStatus.pending,
55-
);
51+
await adminBackend.loadAndVerifyModerationCaseForAdminAction(caseId);
5652

5753
User? user;
5854
if (looksLikeUserId(userIdOrEmail!)) {

app/lib/admin/backend.dart

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -753,14 +753,13 @@ class AdminBackend {
753753
dbService.emptyKey.append(ModerationCase, id: caseId));
754754
}
755755

756-
/// Returns a valid [ModerationCase] if it exists and [status] is matching.
756+
/// Returns a valid [ModerationCase] if it exists.
757757
/// Returns `null` if [caseId] is `none`.
758758
///
759759
/// Throws exceptions otherwise.
760760
Future<ModerationCase?> loadAndVerifyModerationCaseForAdminAction(
761-
String? caseId, {
762-
required String? status,
763-
}) async {
761+
String? caseId,
762+
) async {
764763
InvalidInputException.check(
765764
caseId != null && caseId.isNotEmpty,
766765
'case must be given',
@@ -773,10 +772,6 @@ class AdminBackend {
773772
if (refCase == null) {
774773
throw NotFoundException.resource(caseId);
775774
}
776-
if (status != null && refCase.status != status) {
777-
throw InvalidInputException(
778-
'ModerationCase.status ("${refCase.status}") != "$status".');
779-
}
780775
return refCase;
781776
}
782777

app/test/admin/moderate_package_test.dart

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -398,22 +398,6 @@ void main() {
398398
},
399399
);
400400

401-
testWithProfile('status already closed', fn: () async {
402-
final mc = await _report('oxygen');
403-
await dbService.commit(inserts: [
404-
mc
405-
..resolved = clock.now()
406-
..status = ModerationStatus.noAction
407-
]);
408-
409-
await expectApiException(
410-
_moderate('oxygen', state: true, caseId: mc.caseId),
411-
code: 'InvalidInput',
412-
status: 400,
413-
message: 'ModerationCase.status ("no-action") != "pending".',
414-
);
415-
});
416-
417401
testWithProfile(
418402
'cleanup deletes datastore entities and canonical archive file',
419403
expectedLogMessages: [

app/test/admin/moderate_publisher_test.dart

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -191,22 +191,6 @@ void main() {
191191
expect(docs3!.where((d) => d.package == 'neon'), isNotEmpty);
192192
});
193193

194-
testWithProfile('status already closed', fn: () async {
195-
final mc = await _report('example.com');
196-
await dbService.commit(inserts: [
197-
mc
198-
..resolved = clock.now()
199-
..status = ModerationStatus.noAction
200-
]);
201-
202-
await expectApiException(
203-
_moderate('example.com', state: true, caseId: mc.caseId),
204-
code: 'InvalidInput',
205-
status: 400,
206-
message: 'ModerationCase.status ("no-action") != "pending".',
207-
);
208-
});
209-
210194
testWithProfile('cleanup deletes datastore entities and abandons packages',
211195
fn: () async {
212196
// moderate and cleanup

0 commit comments

Comments
 (0)