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

ModerationCase entity #7614

Merged
merged 4 commits into from
Apr 9, 2024
Merged
Changes from 1 commit
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
87 changes: 87 additions & 0 deletions app/lib/admin/models.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
// 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:clock/clock.dart';
import 'package:pub_dev/shared/utils.dart';

import '../shared/datastore.dart' as db;

/// Tracks the status of the moderation or appeal case.
@db.Kind(name: 'ModerationCase', idType: db.IdType.String)
class ModerationCase extends db.ExpandoModel<String> {
/// Same as [id].
/// A random UUID id.
String get caseId => id!;

/// The `userId` of the reporter (may be null for non-authenticated reporter).
@db.StringProperty()
String? reporterUserId;

/// The email of the reporter.
@db.StringProperty(required: true)
late String reporterEmail;

/// The case was opened at this time.
@db.DateTimeProperty(required: true)
late DateTime opened;

/// The case was resolved at this time (or null if it has not been resolved yet).
@db.DateTimeProperty()
DateTime? resolved;

/// The source of the case, one of:
/// - `external-notification`,
/// - `internal-notification` (only used for reports from @google.com accounts), or,
/// - `automated-detection. (will not be used)
@db.StringProperty(required: true)
late String detectedBy;

/// The kind of the case, one of:
/// - `notification`, or,
/// - `appeal`
@db.StringProperty(required: true)
late String kind;

/// The package this notification or appeal concerns.
/// In the case of an appeal, reporter must be owner of said package.
@db.StringProperty()
String? subjectPackage;

/// The publisher this notification or appeal concerns.
/// In the case of an appeal, reporter must be a member of said publisher.
@db.StringProperty()
String? subjectPublisher;

/// The `caseId` of the appeal (or null).
@db.StringProperty()
String? appealedCaseId;

/// One of:
/// - `no-action`, if this is a notification (kind = notification) and
/// we decided to take no action.
/// - `moderation-applied`, if this is a notification (kind = notification) and
/// we decided to apply content moderation.
/// - `no-action-upheld`, if this is an appeal (kind = appeal) of a notification
/// where we took no-action, and we decided to uphold that decision.
/// - `no-action-reverted`, if this is an appeal (kind = appeal) of a notification
/// where we took no-action, and we decided to revert that decision.
/// - `moderation-upheld`, if this is an appeal (kind = appeal) of a notification
/// where we applied content moderation, and we decided to uphold that decision.
/// - `moderation-reverted`, if this is an appeal (kind = appeal) of a notification
/// where we applied content moderation, and we decided to revert that decision.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps document the null case.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we shouldn't allow null? E.g. pending could indicate the in-progress state, and it is also possible to filter for it...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SG

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IF we want a pending thing, we should rename it status.

For querying it's probably fine to have a pending value.

@db.StringProperty()
String? resolution;

ModerationCase();

ModerationCase.init({
required this.reporterUserId,
required this.reporterEmail,
required this.detectedBy,
required this.kind,
}) {
id = createUuid();
opened = clock.now().toUtc();
}
}
Loading