related false when objects do not exist

This commit is contained in:
Paul Zinselmeyer 2023-04-30 11:55:34 +02:00
parent 47ab190761
commit fb68b47c5b
Signed by: pfzetto
GPG key ID: 4EEF46A5B276E648
3 changed files with 17 additions and 11 deletions

View file

@ -1,10 +1,12 @@
[user:bob] [test:hello]
[doc:foo] [doc:foo]
read = [doc:foo#owner, user:bob]
owner = [user:alice] owner = [user:alice]
read = [user:bob, doc:foo#owner]
[user:oscar]
[user:alice] [user:alice]
[user:bob]
[user:oscar]

View file

@ -1,10 +1,12 @@
[user:bob] [test:hello]
[doc:foo] [doc:foo]
read = [user:bob, doc:foo#owner] read = [doc:foo#owner, user:bob]
owner = [user:alice] owner = [user:alice]
[user:oscar]
[user:alice] [user:alice]
[user:bob]
[user:oscar]

View file

@ -126,9 +126,11 @@ impl QueryService for GraphService {
) -> Result<Response<IsRelatedToResponse>, Status> { ) -> Result<Response<IsRelatedToResponse>, Status> {
let graph = self.graph.lock().await; let graph = self.graph.lock().await;
let (src, dst) = transform_relation(request.get_ref(), &graph)?; let related = if let Ok((src, dst)) = transform_relation(request.get_ref(), &graph) {
graph.is_related_to(src, dst)
let related = graph.is_related_to(src, dst); } else {
false
};
Ok(Response::new(IsRelatedToResponse { related })) Ok(Response::new(IsRelatedToResponse { related }))
} }