Complete customer transfers on first authenticated inventory
Rust development slice / linux (push) Failing after 8s
Rust development slice / linux (push) Failing after 8s
This commit is contained in:
@@ -105,7 +105,7 @@ pub async fn ingest(
|
||||
);
|
||||
let mut tx = rmm_persistence::tenant_tx(&state.pool, tenant).await?;
|
||||
control_lock(&mut tx, tenant, agent).await?;
|
||||
let row=sqlx::query("SELECT revoked_at,connection_generation,transport,connection_boot_id,last_sequence,capabilities FROM agent_installations WHERE agent_id=$1 FOR UPDATE").bind(agent).fetch_one(&mut *tx).await?;
|
||||
let row=sqlx::query("SELECT revoked_at,connection_generation,transport,connection_boot_id,last_sequence,capabilities,customer_transfer_pending FROM agent_installations WHERE agent_id=$1 FOR UPDATE").bind(agent).fetch_one(&mut *tx).await?;
|
||||
let active = row.get::<Option<DateTime<Utc>>, _>("revoked_at").is_none()
|
||||
&& row.get::<i64, _>("connection_generation") == i64::try_from(e.connection_generation)?
|
||||
&& row.get::<String, _>("transport") == transport;
|
||||
@@ -196,6 +196,16 @@ pub async fn ingest(
|
||||
}
|
||||
_ => anyhow::bail!("unsupported capability"),
|
||||
}
|
||||
if row.get::<bool, _>("customer_transfer_pending")
|
||||
&& (matches!(&e.payload, Some(Payload::Heartbeat(_)))
|
||||
|| matches!(&e.payload, Some(Payload::InventorySnapshot(s)) if s.scope != "agent.update"))
|
||||
{
|
||||
sqlx::query("SELECT finish_device_customer_transfer($1,$2)")
|
||||
.bind(tenant)
|
||||
.bind(agent)
|
||||
.execute(&mut *tx)
|
||||
.await?;
|
||||
}
|
||||
tx.commit().await?;
|
||||
Ok(reply(
|
||||
e,
|
||||
|
||||
Reference in New Issue
Block a user