Skip to content

Commit

Permalink
Remove isBlocked-related admin operations. (dart-lang#8357)
Browse files Browse the repository at this point in the history
  • Loading branch information
isoos authored Dec 5, 2024
1 parent e5889f7 commit 5410814
Show file tree
Hide file tree
Showing 16 changed files with 16 additions and 354 deletions.
2 changes: 0 additions & 2 deletions app/lib/admin/actions/actions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import 'package_reservation_delete.dart';
import 'package_reservation_list.dart';
import 'package_version_info.dart';
import 'package_version_retraction.dart';
import 'publisher_block.dart';
import 'publisher_create.dart';
import 'publisher_delete.dart';
import 'publisher_info.dart';
Expand Down Expand Up @@ -114,7 +113,6 @@ final class AdminAction {
packageReservationList,
packageVersionInfo,
packageVersionRetraction,
publisherBlock,
publisherCreate,
publisherDelete,
publisherInfo,
Expand Down
62 changes: 0 additions & 62 deletions app/lib/admin/actions/publisher_block.dart

This file was deleted.

6 changes: 0 additions & 6 deletions app/lib/admin/backend.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,11 @@ import '../shared/versions.dart';
import '../task/backend.dart';
import 'actions/actions.dart' show AdminAction;
import 'tools/delete_all_staging.dart';
import 'tools/list_package_blocked.dart';
import 'tools/list_tools.dart';
import 'tools/notify_service.dart';
import 'tools/package_publisher.dart';
import 'tools/publisher_member.dart';
import 'tools/recent_uploaders.dart';
import 'tools/set_package_blocked.dart';
import 'tools/set_user_blocked.dart';
import 'tools/user_merger.dart';

final _logger = Logger('pub.admin.backend');
Expand All @@ -59,14 +56,11 @@ typedef Tool = Future<String> Function(List<String> args);

final Map<String, Tool> availableTools = {
'delete-all-staging': executeDeleteAllStaging,
'list-package-blocked': executeListPackageBlocked,
'notify-service': executeNotifyService,
'package-publisher': executeSetPackagePublisher,
'recent-uploaders': executeRecentUploaders,
'publisher-member': executePublisherMember,
'publisher-invite-member': executePublisherInviteMember,
'set-package-blocked': executeSetPackageBlocked,
'set-user-blocked': executeSetUserBlocked,
'user-merger': executeUserMergerTool,
'list-tools': executeListTools,
};
Expand Down
27 changes: 0 additions & 27 deletions app/lib/admin/tools/list_package_blocked.dart

This file was deleted.

107 changes: 0 additions & 107 deletions app/lib/admin/tools/set_package_blocked.dart

This file was deleted.

50 changes: 0 additions & 50 deletions app/lib/admin/tools/set_user_blocked.dart

This file was deleted.

10 changes: 0 additions & 10 deletions app/lib/package/models.dart
Original file line number Diff line number Diff line change
Expand Up @@ -413,16 +413,6 @@ class Package extends db.ExpandoModel<String> {
);
}

void updateIsBlocked({
required bool isBlocked,
String? reason,
}) {
this.isBlocked = isBlocked;
blockedReason = reason;
blocked = isBlocked ? clock.now().toUtc() : null;
updated = clock.now().toUtc();
}

void updateIsModerated({
required bool isModerated,
}) {
Expand Down
9 changes: 0 additions & 9 deletions app/lib/publisher/models.dart
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,6 @@ class Publisher extends db.ExpandoModel<String> {
isModerated = false;
}

/// Clears most properties on the entity and sets the [isBlocked] flag.
void markForBlocked() {
isBlocked = true;
isAbandoned = true;
contactEmail = null;
description = '';
updated = clock.now().toUtc();
}

/// Whether the publisher has a displayable description.
bool get hasDescription => description != null && description!.isNotEmpty;

Expand Down
20 changes: 0 additions & 20 deletions app/test/admin/api_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -712,26 +712,6 @@ void main() {
expect(rs3.isRetracted, v4.isRetracted);
});
});

group('block user', () {
setupTestsWithAdminTokenIssues(
(client) => client.adminExecuteTool(
'set-user-blocked',
'[email protected]/true',
),
);

testWithProfile('block and unblock user', fn: () async {
final client = createPubApiClient(authToken: siteAdminToken);
await client.adminExecuteTool('set-user-blocked', '[email protected]/true');
final user = await accountBackend.lookupUserByEmail('[email protected]');
expect(user.isBlocked, true);
await client.adminExecuteTool(
'set-user-blocked', '${user.userId}/false');
final user2 = await accountBackend.lookupUserByEmail('[email protected]');
expect(user2.isBlocked, false);
});
});
});
}

Expand Down
4 changes: 2 additions & 2 deletions app/test/frontend/handlers/custom_api_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ void main() {
},
);
final p = await packageBackend.lookupPackage('neon');
p!.updateIsBlocked(isBlocked: true, reason: 'spam');
p!.updateIsModerated(isModerated: true);
expect(p.isVisible, isFalse);
await dbService.commit(inserts: [p]);
await nameTracker.reloadFromDatastore();
Expand All @@ -163,7 +163,7 @@ void main() {
);

// reverting to make sure integrity check is passing
p.updateIsBlocked(isBlocked: false);
p.updateIsModerated(isModerated: false);
await dbService.commit(inserts: [p]);
});
});
Expand Down
12 changes: 0 additions & 12 deletions app/test/frontend/handlers/documentation_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'package:gcloud/db.dart';
import 'package:pub_dev/frontend/handlers/documentation.dart';
import 'package:pub_dev/package/backend.dart';
import 'package:pub_dev/shared/urls.dart';
import 'package:test/test.dart';

Expand Down Expand Up @@ -143,15 +141,5 @@ void main() {
},
processJobsWithFakeRunners: true,
);

testWithProfile('withheld package gets rejected', fn: () async {
final pkg = await packageBackend.lookupPackage('oxygen');
await dbService.commit(inserts: [pkg!..updateIsBlocked(isBlocked: true)]);
await expectNotFoundResponse(
await issueGet('/documentation/oxygen/latest/'));

// reverting to make sure integrity check is passing
await dbService.commit(inserts: [pkg..updateIsBlocked(isBlocked: false)]);
});
});
}
Loading

0 comments on commit 5410814

Please sign in to comment.