Git Workflow and Impl ws new item message
This commit is contained in:
@@ -74,6 +74,24 @@ pub async fn update_inventory_item(
|
||||
){
|
||||
return (StatusCode::INTERNAL_SERVER_ERROR, format!("failed to update inventory history"));
|
||||
}
|
||||
|
||||
if let Some(hotel_users) = state.ws_map.get(&hotel_id) {
|
||||
let update_msg = json!({
|
||||
"event_type": "item_update",
|
||||
"item_id": item_id,
|
||||
"number": item_amount,
|
||||
"updated_by": user_id,
|
||||
})
|
||||
.to_string();
|
||||
|
||||
for entry in hotel_users.iter() {
|
||||
let sender = entry.value();
|
||||
// ignore errors (client disconnected)
|
||||
let _ = sender.send(Message::Text(update_msg.clone().into()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
(StatusCode::OK, format!("updated item history"))
|
||||
}
|
||||
|
||||
@@ -82,6 +100,9 @@ pub async fn update_inventory_item(
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
match result {
|
||||
Ok(row) => (StatusCode::OK, format!("Items updated")),
|
||||
|
||||
Reference in New Issue
Block a user