Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ModerationSource values and documentation. #8088

Merged
merged 3 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/lib/admin/actions/moderation_case_create.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Returns the fields on the newly created moderation case.
'The email of the reporter. (default value: `support@pub.dev`)',
'kind': 'The kind of the moderation case. (default value: `notification`)',
'source':
'The source of the moderation case. (default value: `internal-notification`)',
'The source of the moderation case. (default value: `trusted-flagger`)',
'subject': 'The subject of the moderation case.',
'url': 'The url of the moderation case (optional).'
},
Expand All @@ -37,7 +37,7 @@ Returns the fields on the newly created moderation case.
InvalidInputException.check(
ModerationKind.isValidKind(kind), 'invalid kind');

final source = options['source'] ?? ModerationSource.internalNotification;
final source = options['source'] ?? ModerationSource.trustedFlagger;
InvalidInputException.check(
ModerationSource.isValidSource(source), 'invalid source');

Expand Down
8 changes: 5 additions & 3 deletions app/lib/admin/models.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ class ModerationCase extends db.ExpandoModel<String> {

/// The source of the case, one of:
/// - `external-notification`,
/// - `internal-notification` (only used for reports from @google.com accounts), or,
/// - `trusted-flagger`,
/// - `authorities`,
/// - `legal-referral`,
/// - `automated-detection`. (will not be used)
@db.StringProperty(required: true)
late String source;
Expand Down Expand Up @@ -199,17 +201,17 @@ class ModerationCase extends db.ExpandoModel<String> {

abstract class ModerationSource {
static const externalNotification = 'external-notification';
static const internalNotification = 'internal-notification';
static const trustedFlagger = 'trusted-flagger';
static const authorities = 'authorities';
static const legalReferral = 'legal-referral';
static const automatedDetection = 'automated-detection';

static const _values = [
externalNotification,
internalNotification,
trustedFlagger,
authorities,
legalReferral,
automatedDetection,
];
static bool isValidSource(String value) => _values.contains(value);
}
Expand Down
2 changes: 1 addition & 1 deletion app/test/admin/moderation_case_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ void main() {
'kind': 'notification',
'opened': isNotEmpty,
'resolved': null,
'source': 'internal-notification',
'source': 'trusted-flagger',
'subject': 'package:oxygen',
'isSubjectOwner': false,
'url': null,
Expand Down
Loading