Progress on refactoring and abiding by cargo clippy

This commit is contained in:
quexeky
2024-10-15 12:32:04 +11:00
parent b3963b60b5
commit 816b427781
4 changed files with 16 additions and 13 deletions

View File

@ -27,8 +27,9 @@ struct InitiateRequestBody {
}
#[derive(Serialize)]
#[serde(rename_all="camelCase")]
struct HandshakeRequestBody {
clientId: String,
client_id: String,
token: String,
}
@ -78,7 +79,7 @@ pub fn generate_authorization_header() -> String {
let signature = sign_nonce(certs.private, nonce.clone()).unwrap();
return format!("Nonce {} {} {}", certs.clientId, nonce, signature);
return format!("Nonce {} {} {}", certs.client_id, nonce, signature);
}
pub fn fetch_user() -> Result<User, ()> {
@ -125,7 +126,7 @@ pub fn recieve_handshake(app: AppHandle, path: String) {
let client_id = path_chunks.get(1).unwrap();
let token = path_chunks.get(2).unwrap();
let body = HandshakeRequestBody {
clientId: client_id.to_string(),
client_id: client_id.to_string(),
token: token.to_string(),
};
@ -140,7 +141,7 @@ pub fn recieve_handshake(app: AppHandle, path: String) {
handle.auth = Some(DatabaseAuth {
private: response_struct.private,
cert: response_struct.certificate,
clientId: response_struct.id,
client_id: response_struct.id,
});
drop(handle);
DB.save().unwrap();

View File

@ -11,10 +11,11 @@ use serde::Deserialize;
use crate::DB;
#[derive(serde::Serialize, Clone, Deserialize)]
#[serde(rename_all="camelCase")]
pub struct DatabaseAuth {
pub private: String,
pub cert: String,
pub clientId: String,
pub client_id: String,
}
#[derive(serde::Serialize, Clone, Deserialize)]

View File

@ -26,12 +26,13 @@ pub enum AppStatus {
SignedInNeedsReauth,
}
#[derive(Clone, Serialize, Deserialize)]
#[serde(rename_all="camelCase")]
pub struct User {
id: String,
username: String,
admin: bool,
displayName: String,
profilePicture: String,
display_name: String,
profile_picture: String,
}
#[derive(Clone, Serialize)]
@ -48,7 +49,7 @@ fn fetch_state<'a>(state: tauri::State<'_, Mutex<AppState>>) -> Result<AppState,
Ok(cloned_state)
}
fn setup<'a>() -> AppState {
fn setup() -> AppState {
env_logger::Builder::from_env(Env::default().default_filter_or("info")).init();
let is_set_up = db::is_set_up();
@ -119,9 +120,8 @@ pub fn run() {
info!("handling drop:// url");
let binding = event.urls();
let url = binding.get(0).unwrap();
match url.host_str().unwrap() {
"handshake" => recieve_handshake(handle.clone(), url.path().to_string()),
_ => (),
if url.host_str().unwrap() == "handshake" {
recieve_handshake(handle.clone(), url.path().to_string())
}
});

View File

@ -26,8 +26,9 @@ macro_rules! unwrap_or_return {
}
#[derive(Deserialize)]
#[serde(rename_all="camelCase")]
struct DropHealthcheck {
appName: String,
app_name: String,
}
#[tauri::command]
@ -44,7 +45,7 @@ pub async fn use_remote<'a>(
let result = response.json::<DropHealthcheck>().await.unwrap();
if result.appName != "Drop" {
if result.app_name != "Drop" {
warn!("user entered drop endpoint that connected, but wasn't identified as Drop");
return Err("Not a valid Drop endpoint".to_string());
}