Skip to content

Commit

Permalink
Update ModerationSource values and documentation. (#8088)
Browse files Browse the repository at this point in the history
* Update ModerationSource values and documentation.

* Use trusted-flagger as the default value instead of the internal detection.

* updated test
  • Loading branch information
isoos authored Sep 30, 2024
1 parent ef90118 commit 6630cae
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
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

0 comments on commit 6630cae

Please sign in to comment.