From fb68b47c5b310f6cfdabf6c7078b44e87dae74fd Mon Sep 17 00:00:00 2001 From: Paul Z Date: Sun, 30 Apr 2023 11:55:34 +0200 Subject: [PATCH] related false when objects do not exist --- graph.dat | 10 ++++++---- graph.dat.bak | 10 ++++++---- src/grpc_service.rs | 8 +++++--- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/graph.dat b/graph.dat index c4f5c07..b723c60 100644 --- a/graph.dat +++ b/graph.dat @@ -1,10 +1,12 @@ -[user:bob] +[test:hello] [doc:foo] -read = [doc:foo#owner, user:bob] owner = [user:alice] - -[user:oscar] +read = [user:bob, doc:foo#owner] [user:alice] +[user:bob] + +[user:oscar] + diff --git a/graph.dat.bak b/graph.dat.bak index 9dc7a90..20ee74e 100644 --- a/graph.dat.bak +++ b/graph.dat.bak @@ -1,10 +1,12 @@ -[user:bob] +[test:hello] [doc:foo] -read = [user:bob, doc:foo#owner] +read = [doc:foo#owner, user:bob] owner = [user:alice] -[user:oscar] - [user:alice] +[user:bob] + +[user:oscar] + diff --git a/src/grpc_service.rs b/src/grpc_service.rs index 0d8856a..04f5bf0 100644 --- a/src/grpc_service.rs +++ b/src/grpc_service.rs @@ -126,9 +126,11 @@ impl QueryService for GraphService { ) -> Result, Status> { let graph = self.graph.lock().await; - let (src, dst) = transform_relation(request.get_ref(), &graph)?; - - let related = graph.is_related_to(src, dst); + let related = if let Ok((src, dst)) = transform_relation(request.get_ref(), &graph) { + graph.is_related_to(src, dst) + } else { + false + }; Ok(Response::new(IsRelatedToResponse { related })) }