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

Method determine_actor

libs/@local/graph/postgres-store/src/store/postgres/mod.rs:1207–1242  ·  view source on GitHub ↗
(
        &self,
        actor_entity_uuid: ActorEntityUuid,
    )

Source from the content-addressed store, hash-verified

1205
1206 #[tracing::instrument(skip(self))]
1207 async fn determine_actor(
1208 &self,
1209 actor_entity_uuid: ActorEntityUuid,
1210 ) -> Result<Option<ActorId>, Report<DetermineActorError>> {
1211 if actor_entity_uuid.is_public_actor() {
1212 return Ok(None);
1213 }
1214
1215 let row = self
1216 .as_client()
1217 .query_opt(
1218 "SELECT principal_type FROM actor WHERE id = $1",
1219 &[&actor_entity_uuid],
1220 )
1221 .instrument(tracing::info_span!(
1222 "SELECT",
1223 otel.kind = "client",
1224 db.system = "postgresql",
1225 peer.service = "Postgres",
1226 ))
1227 .await
1228 .change_context(DetermineActorError::StoreError)?
1229 .ok_or(DetermineActorError::ActorNotFound { actor_entity_uuid })?;
1230
1231 Ok(Some(match row.get(0) {
1232 PrincipalType::User => ActorId::User(UserId::new(actor_entity_uuid)),
1233 PrincipalType::Machine => ActorId::Machine(MachineId::new(actor_entity_uuid)),
1234 PrincipalType::Ai => ActorId::Ai(AiId::new(actor_entity_uuid)),
1235 principal_type @ (PrincipalType::Web
1236 | PrincipalType::Team
1237 | PrincipalType::WebRole
1238 | PrincipalType::TeamRole) => {
1239 unreachable!("Unexpected actor type: {principal_type:?}")
1240 }
1241 }))
1242 }
1243
1244 #[tracing::instrument(level = "info", skip(self, context_builder))]
1245 async fn build_principal_context(

Callers 7

assign_roleMethod · 0.45
unassign_roleMethod · 0.45
create_user_actorMethod · 0.45
create_org_webMethod · 0.45
create_teamMethod · 0.45
create_entitiesMethod · 0.45

Calls 8

OkInterface · 0.85
is_public_actorMethod · 0.80
as_clientMethod · 0.80
getMethod · 0.65
UserInterface · 0.50
MachineInterface · 0.50
AiInterface · 0.50
change_contextMethod · 0.45

Tested by

no test coverage detected