Skip to content

Commit

Permalink
Fix: automatic resolve status. (#8095)
Browse files Browse the repository at this point in the history
  • Loading branch information
isoos authored Oct 2, 2024
1 parent ff85ce6 commit 73c20ff
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 18 deletions.
4 changes: 2 additions & 2 deletions app/lib/admin/actions/moderation_case_resolve.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Closes the moderation case and updates the status based on the actions logged on

mc.resolved = clock.now().toUtc();

final hasModeratedAction = mc.getActionLog().hasModeratedAction();
final hasModeratedAction = mc.getActionLog().isNotEmpty;

if (status == null) {
if (mc.kind == ModerationKind.notification) {
Expand All @@ -73,7 +73,7 @@ Closes the moderation case and updates the status based on the actions logged on
.emptyKey
.append(ModerationCase, id: mc.appealedCaseId!));
final appealHadModeratedAction =
appealedCase.getActionLog().hasModeratedAction();
appealedCase.getActionLog().isNotEmpty;
if (appealHadModeratedAction) {
status = hasModeratedAction
? ModerationStatus.moderationReverted
Expand Down
16 changes: 1 addition & 15 deletions app/lib/admin/models.dart
Original file line number Diff line number Diff line change
Expand Up @@ -442,21 +442,7 @@ class ModerationActionLog {

Map<String, Object?> toJson() => _$ModerationActionLogToJson(this);

/// Returns true if the final state of the actions has at least one moderation.
bool hasModeratedAction() {
final subjects = <String>{};
for (final entry in entries) {
switch (entry.moderationAction) {
case ModerationAction.apply:
subjects.add(entry.subject);
break;
case ModerationAction.revert:
subjects.remove(entry.subject);
break;
}
}
return subjects.isNotEmpty;
}
bool get isNotEmpty => entries.isNotEmpty;
}

enum ModerationAction {
Expand Down
2 changes: 1 addition & 1 deletion app/test/admin/moderation_case_resolve_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ void main() {
reason: 'The package violated our policy.',
);

final mc = await _prepare(apply: true, appealCaseId: mc1.caseId);
final mc = await _prepare(apply: false, appealCaseId: mc1.caseId);
expect(await _close(mc.caseId), 'moderation-reverted');
});

Expand Down

0 comments on commit 73c20ff

Please sign in to comment.