Skip to content

Commit 26452e3

Browse files
committed
remove random serialized structs
1 parent e02e2c6 commit 26452e3

File tree

2 files changed

+6
-31
lines changed

2 files changed

+6
-31
lines changed

src/index.rs

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use clap::Subcommand;
66
use reqwest::header::USER_AGENT;
77
use semver::VersionReq;
88
use serde::{Deserialize, Serialize};
9+
use serde_json::json;
910
use sha3::{Digest, Sha3_256};
1011
use std::fs;
1112
use std::io::Cursor;
@@ -216,15 +217,6 @@ fn create_mod(download_link: &str, config: &mut Config) {
216217

217218
let client = reqwest::blocking::Client::new();
218219

219-
#[derive(Serialize)]
220-
struct Payload {
221-
download_link: String,
222-
}
223-
224-
let payload = Payload {
225-
download_link: download_link.to_string(),
226-
};
227-
228220
let url = get_index_url("/v1/mods", config);
229221

230222
info!("Creating mod");
@@ -233,7 +225,7 @@ fn create_mod(download_link: &str, config: &mut Config) {
233225
.post(url)
234226
.header(USER_AGENT, "GeodeCLI")
235227
.bearer_auth(config.index_token.clone().unwrap())
236-
.json(&payload)
228+
.json(&json!({ "download_link": download_link }))
237229
.send()
238230
.nice_unwrap("Unable to connect to Geode Index");
239231

@@ -260,15 +252,6 @@ fn update_mod(id: &str, download_link: &str, config: &mut Config) {
260252

261253
let client = reqwest::blocking::Client::new();
262254

263-
#[derive(Serialize)]
264-
struct Payload {
265-
download_link: String,
266-
}
267-
268-
let payload = Payload {
269-
download_link: download_link.to_string(),
270-
};
271-
272255
let url = get_index_url(format!("/v1/mods/{}/versions", id), config);
273256

274257
info!("Updating mod");
@@ -277,7 +260,7 @@ fn update_mod(id: &str, download_link: &str, config: &mut Config) {
277260
.post(url)
278261
.header(USER_AGENT, "GeodeCLI")
279262
.bearer_auth(config.index_token.clone().unwrap())
280-
.json(&payload)
263+
.json(&json!({ "download_link": download_link }))
281264
.send()
282265
.nice_unwrap("Unable to connect to Geode Index");
283266

src/index_auth.rs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#[cfg(not(target_os = "android"))]
22
use cli_clipboard::ClipboardProvider;
33
use reqwest::header::USER_AGENT;
4-
use serde::{Deserialize, Serialize};
4+
use serde::Deserialize;
5+
use serde_json::json;
56

67
use crate::{
78
config::Config, done, fatal, index, info, logging::ask_value, server::ApiResponse, warn,
@@ -16,11 +17,6 @@ struct LoginAttempt {
1617
code: String,
1718
}
1819

19-
#[derive(Serialize)]
20-
struct LoginPoll {
21-
uuid: String,
22-
}
23-
2420
#[cfg(not(target_os = "android"))]
2521
pub fn copy_token(token: &str) {
2622
if let Ok(mut ctx) = cli_clipboard::ClipboardContext::new() {
@@ -98,16 +94,12 @@ fn poll_login(
9894
uuid: &str,
9995
config: &mut Config,
10096
) -> Option<String> {
101-
let body: LoginPoll = LoginPoll {
102-
uuid: uuid.to_string(),
103-
};
104-
10597
let response = client
10698
.post(index::get_index_url(
10799
"/v1/login/github/poll",
108100
config,
109101
))
110-
.json(&body)
102+
.json(&json!({ "uuid": uuid }))
111103
.header(USER_AGENT, "GeodeCLI")
112104
.send()
113105
.nice_unwrap("Unable to connect to Geode Index");

0 commit comments

Comments
 (0)