Skip to content

Commit

Permalink
remove random serialized structs
Browse files Browse the repository at this point in the history
  • Loading branch information
camila314 committed Jan 15, 2025
1 parent e02e2c6 commit 26452e3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 31 deletions.
23 changes: 3 additions & 20 deletions src/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Expand All @@ -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");

Expand All @@ -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");
Expand All @@ -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");

Expand Down
14 changes: 3 additions & 11 deletions src/index_auth.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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() {
Expand Down Expand Up @@ -98,16 +94,12 @@ fn poll_login(
uuid: &str,
config: &mut Config,
) -> Option<String> {
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");
Expand Down

0 comments on commit 26452e3

Please sign in to comment.