diff --git a/Shoko.Server/Filters/Legacy/LegacyConditionConverter.cs b/Shoko.Server/Filters/Legacy/LegacyConditionConverter.cs index bbe4f3137..19719c461 100644 --- a/Shoko.Server/Filters/Legacy/LegacyConditionConverter.cs +++ b/Shoko.Server/Filters/Legacy/LegacyConditionConverter.cs @@ -734,12 +734,20 @@ public static FilterExpression GetExpression(List 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 GetExpression(GroupFilterCondition condition, bool suppressErrors = false)