Skip to content

Commit

Permalink
Fix a Legacy Filter Conversion for Exclude All
Browse files Browse the repository at this point in the history
  • Loading branch information
da3dsoul committed Sep 28, 2023
1 parent d47ee19 commit a1ffefa
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions Shoko.Server/Filters/Legacy/LegacyConditionConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -734,12 +734,20 @@ public static FilterExpression<bool> GetExpression(List<GroupFilterCondition> co
if (conditions == null || conditions.Count < 1) return null;
var first = conditions.Select((a, index) => new {Expression= GetExpression(a, suppressErrors), Index=index}).FirstOrDefault(a => a.Expression != null);
if (first == null) return null;
var condition = conditions.Count == 1 ? first.Expression : conditions.Skip(first.Index + 1).Aggregate(first.Expression, (a, b) =>
if (baseCondition == GroupFilterBaseCondition.Exclude)
{
return new NotExpression(conditions.Count == 1 ? first.Expression : conditions.Skip(first.Index + 1).Aggregate(first.Expression, (a, b) =>
{
var result = GetExpression(b, suppressErrors);
return result == null ? a : new OrExpression(a, result);
}));
}

return conditions.Count == 1 ? first.Expression : conditions.Skip(first.Index + 1).Aggregate(first.Expression, (a, b) =>
{
var result = GetExpression(b, suppressErrors);
return result == null ? a : new AndExpression(a, result);
});
return baseCondition == GroupFilterBaseCondition.Exclude ? new NotExpression(condition) : condition;
}

private static FilterExpression<bool> GetExpression(GroupFilterCondition condition, bool suppressErrors = false)
Expand Down

0 comments on commit a1ffefa

Please sign in to comment.