From 26452e355aeb97d4b9c66bd9566b07deaca5aee4 Mon Sep 17 00:00:00 2001 From: camila314 <47485054+camila314@users.noreply.github.com> Date: Wed, 15 Jan 2025 13:14:01 -0600 Subject: [PATCH] remove random serialized structs --- src/index.rs | 23 +++-------------------- src/index_auth.rs | 14 +++----------- 2 files changed, 6 insertions(+), 31 deletions(-) diff --git a/src/index.rs b/src/index.rs index f90d3e5..a2b9d7d 100644 --- a/src/index.rs +++ b/src/index.rs @@ -6,6 +6,7 @@ use clap::Subcommand; use reqwest::header::USER_AGENT; use semver::VersionReq; use serde::{Deserialize, Serialize}; +use serde_json::json; use sha3::{Digest, Sha3_256}; use std::fs; use std::io::Cursor; @@ -216,15 +217,6 @@ fn create_mod(download_link: &str, config: &mut Config) { let client = reqwest::blocking::Client::new(); - #[derive(Serialize)] - struct Payload { - download_link: String, - } - - let payload = Payload { - download_link: download_link.to_string(), - }; - let url = get_index_url("/v1/mods", config); info!("Creating mod"); @@ -233,7 +225,7 @@ fn create_mod(download_link: &str, config: &mut Config) { .post(url) .header(USER_AGENT, "GeodeCLI") .bearer_auth(config.index_token.clone().unwrap()) - .json(&payload) + .json(&json!({ "download_link": download_link })) .send() .nice_unwrap("Unable to connect to Geode Index"); @@ -260,15 +252,6 @@ fn update_mod(id: &str, download_link: &str, config: &mut Config) { let client = reqwest::blocking::Client::new(); - #[derive(Serialize)] - struct Payload { - download_link: String, - } - - let payload = Payload { - download_link: download_link.to_string(), - }; - let url = get_index_url(format!("/v1/mods/{}/versions", id), config); info!("Updating mod"); @@ -277,7 +260,7 @@ fn update_mod(id: &str, download_link: &str, config: &mut Config) { .post(url) .header(USER_AGENT, "GeodeCLI") .bearer_auth(config.index_token.clone().unwrap()) - .json(&payload) + .json(&json!({ "download_link": download_link })) .send() .nice_unwrap("Unable to connect to Geode Index"); diff --git a/src/index_auth.rs b/src/index_auth.rs index 6d9f4ca..a0a9bfc 100644 --- a/src/index_auth.rs +++ b/src/index_auth.rs @@ -1,7 +1,8 @@ #[cfg(not(target_os = "android"))] use cli_clipboard::ClipboardProvider; use reqwest::header::USER_AGENT; -use serde::{Deserialize, Serialize}; +use serde::Deserialize; +use serde_json::json; use crate::{ config::Config, done, fatal, index, info, logging::ask_value, server::ApiResponse, warn, @@ -16,11 +17,6 @@ struct LoginAttempt { code: String, } -#[derive(Serialize)] -struct LoginPoll { - uuid: String, -} - #[cfg(not(target_os = "android"))] pub fn copy_token(token: &str) { if let Ok(mut ctx) = cli_clipboard::ClipboardContext::new() { @@ -98,16 +94,12 @@ fn poll_login( uuid: &str, config: &mut Config, ) -> Option { - let body: LoginPoll = LoginPoll { - uuid: uuid.to_string(), - }; - let response = client .post(index::get_index_url( "/v1/login/github/poll", config, )) - .json(&body) + .json(&json!({ "uuid": uuid })) .header(USER_AGENT, "GeodeCLI") .send() .nice_unwrap("Unable to connect to Geode Index");