Skip to content
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_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
Loading