(
&self,
actor_entity_uuid: ActorEntityUuid,
)
| 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( |
no test coverage detected