From 80631bd9413127df751e645474074497e74a105a Mon Sep 17 00:00:00 2001 From: Ralf Haferkamp Date: Mon, 12 Aug 2024 13:31:49 +0200 Subject: [PATCH] graph: remove some code duplication --- services/graph/pkg/service/v0/users_filter.go | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/services/graph/pkg/service/v0/users_filter.go b/services/graph/pkg/service/v0/users_filter.go index e3a23ebc21..833c330f75 100644 --- a/services/graph/pkg/service/v0/users_filter.go +++ b/services/graph/pkg/service/v0/users_filter.go @@ -124,18 +124,16 @@ func (g Graph) applyFilterLogical(ctx context.Context, req *godata.GoDataRequest return users, invalidFilterError() } + // As we currently don't suppport the 'has' or 'in' operator, all our + // currently supported user filters of the ExpressionTokenLogical type + // require exactly two operands. + if len(root.Children) != 2 { + return users, invalidFilterError() + } switch root.Token.Value { case "and": - // 'and' needs 2 operands - if len(root.Children) != 2 { - return users, invalidFilterError() - } return g.applyFilterLogicalAnd(ctx, req, root.Children[0], root.Children[1]) case "or": - // 'or' needs 2 operands - if len(root.Children) != 2 { - return users, invalidFilterError() - } return g.applyFilterLogicalOr(ctx, req, root.Children[0], root.Children[1]) } logger.Debug().Str("Token", root.Token.Value).Msg("unsupported logical filter")