Anticipate relay ID collision
This commit is contained in:
parent
87fb3360fb
commit
6028be92ef
@ -39,6 +39,15 @@ pub async fn create(actor: WebEnergyActor, req: web::Json<CreateDeviceRelayReque
|
|||||||
return Ok(HttpResponse::BadRequest().json("Too many relays for the target device!"));
|
return Ok(HttpResponse::BadRequest().json("Too many relays for the target device!"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if actor
|
||||||
|
.send(energy_actor::GetSingleRelay(req.relay.id))
|
||||||
|
.await?
|
||||||
|
.is_some()
|
||||||
|
{
|
||||||
|
log::error!("Invalid relay create query: A relay with the same ID already exists!");
|
||||||
|
return Ok(HttpResponse::BadRequest().json("A relay with the same ID already exists!"));
|
||||||
|
}
|
||||||
|
|
||||||
// Create the device
|
// Create the device
|
||||||
actor
|
actor
|
||||||
.send(energy_actor::CreateDeviceRelay(
|
.send(energy_actor::CreateDeviceRelay(
|
||||||
|
Loading…
Reference in New Issue
Block a user