Parse sync response from server
This commit is contained in:
@ -2,6 +2,7 @@ use crate::app_config::AppConfig;
|
||||
use crate::crypto::pki;
|
||||
use crate::devices::device::{DeviceId, DeviceInfo};
|
||||
use crate::energy::energy_actor;
|
||||
use crate::energy::energy_actor::RelaySyncStatus;
|
||||
use crate::server::custom_error::HttpResult;
|
||||
use crate::server::WebEnergyActor;
|
||||
use actix_web::{web, HttpResponse};
|
||||
@ -138,6 +139,11 @@ struct Claims {
|
||||
info: DeviceInfo,
|
||||
}
|
||||
|
||||
#[derive(serde::Serialize)]
|
||||
struct SyncResult {
|
||||
relays: Vec<RelaySyncStatus>,
|
||||
}
|
||||
|
||||
/// Synchronize device
|
||||
pub async fn sync_device(body: web::Json<SyncRequest>, actor: WebEnergyActor) -> HttpResult {
|
||||
// First, we need to extract device kid from query
|
||||
@ -199,9 +205,9 @@ pub async fn sync_device(body: web::Json<SyncRequest>, actor: WebEnergyActor) ->
|
||||
}
|
||||
};
|
||||
|
||||
let res = actor
|
||||
let relays = actor
|
||||
.send(energy_actor::SynchronizeDevice(device.id, c.claims.info))
|
||||
.await??;
|
||||
|
||||
Ok(HttpResponse::Ok().json(res))
|
||||
Ok(HttpResponse::Ok().json(SyncResult { relays }))
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
pub mod files_utils;
|
||||
pub mod math_utils;
|
||||
pub mod math_utils;
|
||||
pub mod time_utils;
|
||||
|
Reference in New Issue
Block a user