MCPcopy Create free account
hub / github.com/hashintel/hash / into_future

Method into_future

libs/@local/graph/authorization/src/policies/components.rs:585–731  ·  view source on GitHub ↗
(mut self)

Source from the content-addressed store, hash-verified

583
584 #[tracing::instrument(level = "info", skip(self))]
585 fn into_future(mut self) -> Self::IntoFuture {
586 async move {
587 let actor_id = match self.actor {
588 AuthenticatedActor::Id(actor_id) => Some(actor_id),
589 AuthenticatedActor::Uuid(actor_uuid) => self
590 .store
591 .determine_actor(actor_uuid)
592 .await
593 .change_context(ContextCreationError::DetermineActor {
594 actor_id: actor_uuid,
595 })?,
596 };
597
598 if let Some(actor_id) = actor_id {
599 self.store
600 .build_principal_context(actor_id, &mut self.context)
601 .await
602 .change_context(ContextCreationError::BuildPrincipalContext { actor_id })?;
603 } else {
604 self.context.add_public_actor();
605 }
606
607 let entity_resources;
608 let mut entity_type_ids = self.entity_type_ids;
609 if !self.entity_edition_ids.is_empty() {
610 entity_resources = self
611 .store
612 .build_entity_context(
613 &self.entity_edition_ids.iter().copied().collect::<Vec<_>>(),
614 )
615 .await
616 .change_context(ContextCreationError::BuildEntityContext {
617 entity_edition_ids: self.entity_edition_ids,
618 })?;
619 for entity_resource in &entity_resources {
620 self.context.add_entity(entity_resource);
621 entity_type_ids.extend(entity_resource.entity_types.iter().map(Cow::Borrowed));
622 }
623 }
624
625 let tracked_entity_types = if entity_type_ids.is_empty() {
626 HashSet::new()
627 } else {
628 let entity_type_ids = entity_type_ids.iter().map(Cow::as_ref).collect::<Vec<_>>();
629 let entity_type_resources = self
630 .store
631 .build_entity_type_context(&entity_type_ids)
632 .await
633 .change_context_lazy(|| ContextCreationError::BuildEntityTypeContext {
634 entity_type_ids: entity_type_ids.into_iter().cloned().collect(),
635 })?;
636 for entity_type_resource in &entity_type_resources {
637 self.context.add_entity_type(entity_type_resource);
638 }
639 entity_type_resources
640 .into_iter()
641 .map(|resource| resource.id.into_owned().into_url())
642 .collect::<HashSet<_>>()

Callers

nothing calls this directly

Calls 15

OkInterface · 0.85
add_public_actorMethod · 0.80
collectMethod · 0.80
change_contextMethod · 0.45
determine_actorMethod · 0.45
is_emptyMethod · 0.45
build_entity_contextMethod · 0.45
iterMethod · 0.45
add_entityMethod · 0.45
extendMethod · 0.45

Tested by

no test coverage detected