Skip to content

Commit 73c20ff

Browse files
authored
Fix: automatic resolve status. (#8095)
1 parent ff85ce6 commit 73c20ff

File tree

3 files changed

+4
-18
lines changed

3 files changed

+4
-18
lines changed

app/lib/admin/actions/moderation_case_resolve.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ Closes the moderation case and updates the status based on the actions logged on
6161

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

64-
final hasModeratedAction = mc.getActionLog().hasModeratedAction();
64+
final hasModeratedAction = mc.getActionLog().isNotEmpty;
6565

6666
if (status == null) {
6767
if (mc.kind == ModerationKind.notification) {
@@ -73,7 +73,7 @@ Closes the moderation case and updates the status based on the actions logged on
7373
.emptyKey
7474
.append(ModerationCase, id: mc.appealedCaseId!));
7575
final appealHadModeratedAction =
76-
appealedCase.getActionLog().hasModeratedAction();
76+
appealedCase.getActionLog().isNotEmpty;
7777
if (appealHadModeratedAction) {
7878
status = hasModeratedAction
7979
? ModerationStatus.moderationReverted

app/lib/admin/models.dart

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -442,21 +442,7 @@ class ModerationActionLog {
442442

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

445-
/// Returns true if the final state of the actions has at least one moderation.
446-
bool hasModeratedAction() {
447-
final subjects = <String>{};
448-
for (final entry in entries) {
449-
switch (entry.moderationAction) {
450-
case ModerationAction.apply:
451-
subjects.add(entry.subject);
452-
break;
453-
case ModerationAction.revert:
454-
subjects.remove(entry.subject);
455-
break;
456-
}
457-
}
458-
return subjects.isNotEmpty;
459-
}
445+
bool get isNotEmpty => entries.isNotEmpty;
460446
}
461447

462448
enum ModerationAction {

app/test/admin/moderation_case_resolve_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ void main() {
115115
reason: 'The package violated our policy.',
116116
);
117117

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

0 commit comments

Comments
 (0)