Clean up (mostly automated with cargo clippy --fix)
This commit is contained in:
parent
979ec6b4fa
commit
d68c93b5fa
36 changed files with 364 additions and 393 deletions
|
@ -50,7 +50,7 @@ pub async fn get_device_route(
|
|||
|
||||
let device = db
|
||||
.users
|
||||
.get_device_metadata(&sender_user, &body.body.device_id)?
|
||||
.get_device_metadata(sender_user, &body.body.device_id)?
|
||||
.ok_or(Error::BadRequest(ErrorKind::NotFound, "Device not found."))?;
|
||||
|
||||
Ok(get_device::Response { device }.into())
|
||||
|
@ -72,13 +72,13 @@ pub async fn update_device_route(
|
|||
|
||||
let mut device = db
|
||||
.users
|
||||
.get_device_metadata(&sender_user, &body.device_id)?
|
||||
.get_device_metadata(sender_user, &body.device_id)?
|
||||
.ok_or(Error::BadRequest(ErrorKind::NotFound, "Device not found."))?;
|
||||
|
||||
device.display_name = body.display_name.clone();
|
||||
|
||||
db.users
|
||||
.update_device_metadata(&sender_user, &body.device_id, &device)?;
|
||||
.update_device_metadata(sender_user, &body.device_id, &device)?;
|
||||
|
||||
db.flush()?;
|
||||
|
||||
|
@ -119,8 +119,8 @@ pub async fn delete_device_route(
|
|||
|
||||
if let Some(auth) = &body.auth {
|
||||
let (worked, uiaainfo) = db.uiaa.try_auth(
|
||||
&sender_user,
|
||||
&sender_device,
|
||||
sender_user,
|
||||
sender_device,
|
||||
auth,
|
||||
&uiaainfo,
|
||||
&db.users,
|
||||
|
@ -133,13 +133,13 @@ pub async fn delete_device_route(
|
|||
} else if let Some(json) = body.json_body {
|
||||
uiaainfo.session = Some(utils::random_string(SESSION_ID_LENGTH));
|
||||
db.uiaa
|
||||
.create(&sender_user, &sender_device, &uiaainfo, &json)?;
|
||||
.create(sender_user, sender_device, &uiaainfo, &json)?;
|
||||
return Err(Error::Uiaa(uiaainfo));
|
||||
} else {
|
||||
return Err(Error::BadRequest(ErrorKind::NotJson, "Not json."));
|
||||
}
|
||||
|
||||
db.users.remove_device(&sender_user, &body.device_id)?;
|
||||
db.users.remove_device(sender_user, &body.device_id)?;
|
||||
|
||||
db.flush()?;
|
||||
|
||||
|
@ -182,8 +182,8 @@ pub async fn delete_devices_route(
|
|||
|
||||
if let Some(auth) = &body.auth {
|
||||
let (worked, uiaainfo) = db.uiaa.try_auth(
|
||||
&sender_user,
|
||||
&sender_device,
|
||||
sender_user,
|
||||
sender_device,
|
||||
auth,
|
||||
&uiaainfo,
|
||||
&db.users,
|
||||
|
@ -196,14 +196,14 @@ pub async fn delete_devices_route(
|
|||
} else if let Some(json) = body.json_body {
|
||||
uiaainfo.session = Some(utils::random_string(SESSION_ID_LENGTH));
|
||||
db.uiaa
|
||||
.create(&sender_user, &sender_device, &uiaainfo, &json)?;
|
||||
.create(sender_user, sender_device, &uiaainfo, &json)?;
|
||||
return Err(Error::Uiaa(uiaainfo));
|
||||
} else {
|
||||
return Err(Error::BadRequest(ErrorKind::NotJson, "Not json."));
|
||||
}
|
||||
|
||||
for device_id in &body.devices {
|
||||
db.users.remove_device(&sender_user, &device_id)?
|
||||
db.users.remove_device(sender_user, device_id)?
|
||||
}
|
||||
|
||||
db.flush()?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue