fix: fixed handling of new beacons
This commit is contained in:
parent
e0af4ad291
commit
ceb4aa808e
@ -66,8 +66,6 @@ where
|
|||||||
let mut config: messages::BeaconConfig = {
|
let mut config: messages::BeaconConfig = {
|
||||||
let client = callback::obtain_https_client(&host_adapter, ¶ms).await?;
|
let client = callback::obtain_https_client(&host_adapter, ¶ms).await?;
|
||||||
|
|
||||||
dbg!(¶ms.beacon_identifier);
|
|
||||||
|
|
||||||
make_request(
|
make_request(
|
||||||
&client,
|
&client,
|
||||||
format!("https://{}/checkin", params::domain_name::<A>(¶ms)?).parse()?,
|
format!("https://{}/checkin", params::domain_name::<A>(¶ms)?).parse()?,
|
||||||
|
|||||||
@ -94,15 +94,18 @@ pub async fn handle_checkin(
|
|||||||
.fetch_optional(&state.db)
|
.fetch_optional(&state.db)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
if let Some(category_id) = template_category.map(|r| r.default_category) {
|
if let Some(category_id) = template_category.map(|r| r.default_category).flatten() {
|
||||||
sqlx::query!(
|
if let Err(e) = sqlx::query!(
|
||||||
"INSERT INTO beacon_category_assignment (category_id, beacon_id)
|
"INSERT INTO beacon_category_assignment (category_id, beacon_id)
|
||||||
VALUES (?, ?)",
|
VALUES (?, ?)",
|
||||||
category_id,
|
category_id,
|
||||||
reg.beacon_id
|
reg.beacon_id
|
||||||
)
|
)
|
||||||
.execute(&state.db)
|
.execute(&state.db)
|
||||||
.await?;
|
.await {
|
||||||
|
tracing::warn!("Could not assign beacon to default category: {e:?}");
|
||||||
|
return Err(e.into());
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
sqlx::query!(
|
sqlx::query!(
|
||||||
@ -138,6 +141,7 @@ pub async fn handle_checkin(
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
tracing::debug!("Here 5");
|
||||||
let now = chrono::Utc::now();
|
let now = chrono::Utc::now();
|
||||||
sqlx::query!(
|
sqlx::query!(
|
||||||
r"INSERT INTO beacon_checkin (beacon_id, checkin_date) VALUES (?, ?)"r,
|
r"INSERT INTO beacon_checkin (beacon_id, checkin_date) VALUES (?, ?)"r,
|
||||||
|
|||||||
@ -469,7 +469,8 @@ async fn handle_listener_events(
|
|||||||
category_ids: category_ids.iter().map(|r| r.category_id).collect()
|
category_ids: category_ids.iter().map(|r| r.category_id).collect()
|
||||||
};
|
};
|
||||||
|
|
||||||
socket.send(ws::Message::Text(serde_json::to_string(&beacon)?)).await?;
|
let json = serde_json::to_string(&SidebarEvents::NewBeacon(beacon))?;
|
||||||
|
socket.send(ws::Message::Text(json)).await?;
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
tracing::warn!("Unable to handle general event: {e:?}");
|
tracing::warn!("Unable to handle general event: {e:?}");
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user