feat: finished adding handler for new beacons
This commit is contained in:
parent
e103fa9f28
commit
9fee4009f2
@ -439,7 +439,7 @@ async fn handle_listener_events(
|
||||
socket.send(ws::Message::Text(serde_json::to_string(&SidebarEvents::Checkin(bid.clone()))?)).await?;
|
||||
}
|
||||
Ok(BeaconEvent::NewBeacon(bid)) => {
|
||||
let beacons = sqlx::query!(
|
||||
let beacon = sqlx::query!(
|
||||
"SELECT template_id, peer_ip, nickname, cwd, operating_system, beacon_userent, hostname, config_id FROM beacon_instance
|
||||
WHERE beacon_id = ?",
|
||||
bid
|
||||
@ -452,8 +452,24 @@ async fn handle_listener_events(
|
||||
WHERE beacon_id = ?",
|
||||
bid
|
||||
)
|
||||
.fetch_one(&state.db)
|
||||
.fetch_all(&state.db)
|
||||
.await?;
|
||||
|
||||
let beacon = CurrentBeaconInstance {
|
||||
beacon_id: bid,
|
||||
template_id: beacon.template_id,
|
||||
ip: beacon.peer_ip,
|
||||
nickname: beacon.nickname,
|
||||
cwd: beacon.cwd,
|
||||
operating_system: beacon.operating_system,
|
||||
userent: beacon.beacon_userent,
|
||||
hostname: beacon.hostname,
|
||||
config_id: beacon.config_id,
|
||||
last_checkin: chrono::Utc::now(),
|
||||
category_ids: category_ids.iter().map(|r| r.category_id).collect()
|
||||
};
|
||||
|
||||
socket.send(ws::Message::Text(serde_json::to_string(&beacon)?)).await?;
|
||||
}
|
||||
Err(e) => {
|
||||
tracing::warn!("Unable to handle general event: {e:?}");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user