construct deletes

This commit is contained in:
ntr
2019-06-06 12:46:07 +10:00
parent 114ec98aba
commit 3fa24566cf
8 changed files with 63 additions and 8 deletions
+1 -1
View File
@@ -803,7 +803,7 @@ pub fn construct_delete(tx: &mut Transaction, id: Uuid, account_id: Uuid) -> Res
let query = "
DELETE
FROM constructs
WHERE id = $1;
WHERE id = $1
and account = $2;
";
+4 -4
View File
@@ -12,11 +12,10 @@ use failure::Error;
use failure::err_msg;
use net::Db;
use construct::{Construct, construct_spawn};
use construct::{Construct, construct_spawn, construct_delete};
use game::{Game, game_state, game_skill, game_ready};
use account::{Account, account_create, account_login, account_from_token, account_constructs, account_instances};
use skill::{Skill};
use spec::{Spec};
use instance::{Instance, instance_state, instance_list, instance_new, instance_ready, instance_join};
use vbox::{vbox_accept, vbox_apply, vbox_discard, vbox_combine, vbox_reclaim, vbox_unequip};
use item::{Item, ItemInfoCtr, item_info};
@@ -72,6 +71,7 @@ impl Rpc {
"account_instances" => Rpc::account_instances(data, &mut tx, account.unwrap(), client),
"construct_spawn" => Rpc::construct_spawn(data, &mut tx, account.unwrap(), client),
"construct_delete" => Rpc::construct_delete(data, &mut tx, account.unwrap(), client),
"game_state" => Rpc::game_state(data, &mut tx, account.unwrap(), client),
"game_skill" => Rpc::game_skill(data, &mut tx, account.unwrap(), client),
@@ -175,10 +175,10 @@ impl Rpc {
Ok(construct_list)
}
fn construct_delete(data: Vec<u8>, tx: &mut Transaction, account: Account, client: &mut WebSocket<TcpStream>) -> Result<RpcResponse, Error> {
fn construct_delete(data: Vec<u8>, tx: &mut Transaction, account: Account, _client: &mut WebSocket<TcpStream>) -> Result<RpcResponse, Error> {
let msg = from_slice::<ConstructDeleteMsg>(&data).or(Err(err_msg("invalid params")))?;
construct_delete(msg.params.id, tx, &account)?;
construct_delete(tx, msg.params.id, account.id)?;
let construct_list = RpcResponse {
method: "account_constructs".to_string(),