fix: all remaining bugs with props
This commit is contained in:
parent
5e14481714
commit
475d1ef90a
8 changed files with 123 additions and 16 deletions
|
|
@ -311,17 +311,18 @@ pub async fn pick_up_loose_prop<'e>(
|
|||
'[]'::jsonb,
|
||||
now()
|
||||
FROM source_info si
|
||||
RETURNING id, prop_name, prop_asset_path, layer, is_transferable, is_portable, is_droppable, acquired_at
|
||||
RETURNING id, server_prop_id, realm_prop_id, prop_name, prop_asset_path, layer, is_transferable, is_portable, is_droppable, origin, acquired_at
|
||||
)
|
||||
SELECT
|
||||
ii.id,
|
||||
COALESCE(ii.server_prop_id, ii.realm_prop_id) as prop_id,
|
||||
ii.prop_name,
|
||||
ii.prop_asset_path,
|
||||
ii.layer,
|
||||
ii.is_transferable,
|
||||
ii.is_portable,
|
||||
ii.is_droppable,
|
||||
'server_library'::server.prop_origin as origin,
|
||||
ii.origin,
|
||||
ii.acquired_at
|
||||
FROM inserted_item ii
|
||||
"#,
|
||||
|
|
@ -620,3 +621,27 @@ pub async fn cleanup_expired_props<'e>(executor: impl PgExecutor<'e>) -> Result<
|
|||
|
||||
Ok(result.rows_affected())
|
||||
}
|
||||
|
||||
/// Delete a loose prop from the scene (moderator action).
|
||||
///
|
||||
/// This permanently removes the prop without adding it to anyone's inventory.
|
||||
pub async fn delete_loose_prop<'e>(
|
||||
executor: impl PgExecutor<'e>,
|
||||
loose_prop_id: Uuid,
|
||||
) -> Result<(), AppError> {
|
||||
let result = sqlx::query(
|
||||
r#"
|
||||
DELETE FROM scene.loose_props
|
||||
WHERE id = $1
|
||||
"#,
|
||||
)
|
||||
.bind(loose_prop_id)
|
||||
.execute(executor)
|
||||
.await?;
|
||||
|
||||
if result.rows_affected() == 0 {
|
||||
return Err(AppError::NotFound("Loose prop not found".to_string()));
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -140,6 +140,12 @@ pub enum ClientMessage {
|
|||
/// Inventory item ID to delete.
|
||||
inventory_item_id: Uuid,
|
||||
},
|
||||
|
||||
/// Delete a loose prop from the scene (moderator only).
|
||||
DeleteLooseProp {
|
||||
/// The loose prop ID to delete.
|
||||
loose_prop_id: Uuid,
|
||||
},
|
||||
}
|
||||
|
||||
/// Server-to-client WebSocket messages.
|
||||
|
|
@ -263,6 +269,14 @@ pub enum ServerMessage {
|
|||
inventory_item_id: Uuid,
|
||||
},
|
||||
|
||||
/// A loose prop was deleted from the scene (by a moderator).
|
||||
LoosePropDeleted {
|
||||
/// ID of the deleted loose prop.
|
||||
prop_id: Uuid,
|
||||
/// User ID who deleted it.
|
||||
deleted_by_user_id: Uuid,
|
||||
},
|
||||
|
||||
/// A prop was updated (scale changed) - clients should update their local copy.
|
||||
PropRefresh {
|
||||
/// The updated prop with all current values.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue