From 4958074aa1df5bb57149fa1c12a6e3344ddaa813 Mon Sep 17 00:00:00 2001 From: Andrea Toska Date: Sun, 27 Apr 2025 11:04:57 +0200 Subject: [PATCH 01/15] feat(mii): add the mii route --- Cargo.lock | 1 + Cargo.toml | 1 + src/nnid/people.rs | 115 +++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 113 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 31fa8ea..5cc2276 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -29,6 +29,7 @@ dependencies = [ "prost", "quick-xml", "rand", + "reqwest", "rocket", "serde", "serde_json", diff --git a/Cargo.toml b/Cargo.toml index 7252c2d..fb981ac 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,6 +46,7 @@ tonic = "0.12.3" prost = "0.13.4" lettre = "0.11.15" rand = "0.8.5" +reqwest = "0.12.12" diff --git a/src/nnid/people.rs b/src/nnid/people.rs index c84910a..c1ffd00 100644 --- a/src/nnid/people.rs +++ b/src/nnid/people.rs @@ -10,18 +10,30 @@ use rocket::{get, post, put, State}; use rocket::serde::{Deserialize, Serialize}; use crate::account::account::{generate_password, Auth, User}; use crate::dsresponse::Ds; -use crate::error::Errors; +use crate::error::{Error, Errors}; use crate::nnid::pid_distribution::next_pid; use crate::nnid::timezones::{OFFSET_FROM_TIMEZONE}; use crate::Pool; use crate::xml::{Xml, YesNoVal}; use crate::email::send_verification_email; use rand::Rng; +use mii::{get_image_png, get_image_tga}; +use minio::s3::client::Client; +use minio::s3::args::PutObjectArgs; +use std::sync::Arc; static S3_URL_STRING: Lazy> = Lazy::new(|| env::var("S3_URL").expect("S3_URL not specified").into_boxed_str() ); +const DATABASE_ERROR: Errors = Errors{ + error: &[ + Error{ + code: "9999", + message: "Internal server error" + } + ] +}; static S3_URL: Lazy = Lazy::new(|| S3_URL_STRING.parse().unwrap() @@ -74,6 +86,17 @@ pub struct Email{ address: Box } +pub struct S3ClientState { + pub client: Arc, +} + +#[derive(Deserialize)] +pub struct UpdateMiiData { + name: Box, + primary: crate::xml::YesNoVal, + data: Box, +} + #[derive(Deserialize, Serialize)] pub struct Mii{ name: Box, @@ -357,8 +380,92 @@ fn build_own_profile(user: User) -> Ds> { } -#[put("/v1/api/people/@me/miis/@primary")] -pub fn change_mii() { - // stubbed(technically requires auth but this doesnt do anything so theres no harm in not doing auth here rn) +#[put("/v1/api/people/@me/miis/@primary", data = "")] +pub async fn refresh_mii_images( + database: &State, + s3: &State, + auth: Auth, + data: Xml, +) -> Result<(), Option>> { + let db = database.inner(); + let pid = auth.pid; + + let mii_data = data.data.as_ref(); + + let result = sqlx::query!( + "UPDATE users SET mii_data = $1 WHERE pid = $2", + mii_data, + pid + ) + .execute(db) + .await; + + if result.is_err() { + return Err(Some(DATABASE_ERROR)); + } + + generate_mii_images(s3.client.clone(), "pn-cdn", pid, mii_data).await; + + Ok(()) } +pub async fn generate_mii_images(client: Arc, bucket: &str, pid: i32, mii_data: &str) { + let user_mii_key = format!("mii/{}", pid); + + // Upload normal face images + if let Some(png_data) = get_image_png(mii_data).await { + let object_content = ObjectContent::from(png_data.clone()); + let _ = client.put_object_content( + bucket, + &format!("{}/normal_face.png", user_mii_key), + object_content + ).send().await.ok(); + } + + if let Some(tga_data) = get_image_tga(mii_data).await { + let object_content = ObjectContent::from(tga_data.clone()); + let _ = client.put_object_content( + bucket, + &format!("{}/standard.tga", user_mii_key), + object_content + ).send().await.ok(); + } + + // Upload expressions + let expressions = [ + "frustrated", + "smile_open_mouth", + "wink_left", + "sorrow", + "surprise_open_mouth" + ]; + + for expression in expressions.iter() { + let url = format!("https://mii-unsecure.ariankordi.net/miis/image.png?data={}&expression={}&type=face&width=128&instance_count=1", mii_data, expression); + + if let Ok(resp) = reqwest::get(&url).await { + if let Ok(bytes) = resp.bytes().await { + let object_content = ObjectContent::from(bytes.to_vec()); + let _ = client.put_object_content( + bucket, + &format!("{}/{}.png", user_mii_key, expression), + object_content + ).send().await.ok(); + } + } + } + + // Upload body + let body_url = format!("https://mii-unsecure.ariankordi.net/miis/image.png?data={}&type=all_body&width=270&instance_count=1", mii_data); + + if let Ok(resp) = reqwest::get(&body_url).await { + if let Ok(bytes) = resp.bytes().await { + let object_content = ObjectContent::from(bytes.to_vec()); + let _ = client.put_object_content( + bucket, + &format!("{}/body.png", user_mii_key), + object_content + ).send().await.ok(); + } + } +} From 2a1b4f8014a64e4e6d55b03de88c299536fb065c Mon Sep 17 00:00:00 2001 From: Andrea Toska Date: Sun, 27 Apr 2025 11:05:49 +0200 Subject: [PATCH 02/15] change function name back --- src/nnid/people.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nnid/people.rs b/src/nnid/people.rs index c1ffd00..1fecdea 100644 --- a/src/nnid/people.rs +++ b/src/nnid/people.rs @@ -381,7 +381,7 @@ fn build_own_profile(user: User) -> Ds> { #[put("/v1/api/people/@me/miis/@primary", data = "")] -pub async fn refresh_mii_images( +pub async fn change_mii( database: &State, s3: &State, auth: Auth, From dc2d283ec1e5001b1bfe58cf77bfa5f5c7d160f1 Mon Sep 17 00:00:00 2001 From: Andrea Toska Date: Sun, 27 Apr 2025 11:09:15 +0200 Subject: [PATCH 03/15] fix(minio): small minio fix --- src/main.rs | 30 ++++++++++++++++++++++++++++++ src/nnid/people.rs | 16 ---------------- 2 files changed, 30 insertions(+), 16 deletions(-) diff --git a/src/main.rs b/src/main.rs index acaab31..49a0513 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,8 +1,13 @@ use std::env; use std::net::{IpAddr, Ipv4Addr, SocketAddr}; +use std::sync::Arc; use std::time::{SystemTime, UNIX_EPOCH}; use dotenvy::dotenv; use juniper::{EmptyMutation, EmptySubscription}; +use minio::s3::ClientBuilder; +use minio::s3::creds::StaticProvider; +use minio::s3::http::BaseUrl; +use once_cell::sync::Lazy; use rocket::fairing::AdHoc; use rocket::http::{ContentType, Header, Status}; use rocket::{catch, catchers, routes, Request}; @@ -11,6 +16,7 @@ use sqlx::Postgres; use sqlx::postgres::PgPoolOptions; use tonic::transport::Server; use crate::graphql::{Query, Schema}; +use crate::nnid::people::S3ClientState; mod xml; mod conntest; @@ -96,8 +102,32 @@ async fn launch() -> _ { .connect(&act_database_url).await .expect("unable to create pool"); + static S3_URL_STRING: Lazy> = Lazy::new(|| + env::var("S3_URL").expect("S3_URL not specified").into_boxed_str() + ); + + static S3_URL: Lazy = Lazy::new(|| + S3_URL_STRING.parse().unwrap() + ); + + static S3_USER: Lazy> = Lazy::new(|| + env::var("S3_USER").expect("S3_USER not specified").into_boxed_str() + ); + + static S3_PASSWD: Lazy> = Lazy::new(|| + env::var("S3_PASSWD").expect("S3_PASSWD not specified").into_boxed_str() + ); + + let s3_client = ClientBuilder::new(S3_URL.clone()) + .provider(Some(Box::new(StaticProvider::new(&S3_USER, &S3_PASSWD, None)))) + .build() + .expect("failed to create s3 client"); + rocket::build() .manage(pool) + .manage(S3ClientState { + client: Arc::new(s3_client), + }) .manage(graphql::Context(graph_pool)) .manage(Schema::new( Query, diff --git a/src/nnid/people.rs b/src/nnid/people.rs index 1fecdea..376a5c6 100644 --- a/src/nnid/people.rs +++ b/src/nnid/people.rs @@ -22,10 +22,6 @@ use minio::s3::client::Client; use minio::s3::args::PutObjectArgs; use std::sync::Arc; -static S3_URL_STRING: Lazy> = Lazy::new(|| - env::var("S3_URL").expect("S3_URL not specified").into_boxed_str() -); - const DATABASE_ERROR: Errors = Errors{ error: &[ Error{ @@ -35,18 +31,6 @@ const DATABASE_ERROR: Errors = Errors{ ] }; -static S3_URL: Lazy = Lazy::new(|| - S3_URL_STRING.parse().unwrap() -); - -static S3_USER: Lazy> = Lazy::new(|| - env::var("S3_USER").expect("S3_USER not specified").into_boxed_str() -); - -static S3_PASSWD: Lazy> = Lazy::new(|| - env::var("S3_PASSWD").expect("S3_PASSWD not specified").into_boxed_str() -); - fn get_mii_img_url_path(pid: i32, format: &str) -> String{ format!("mii/{}/main.{}", pid, format) } From 8a48cab347621ec7ce24cd7bc9e151f490233a1c Mon Sep 17 00:00:00 2001 From: Andrea Toska Date: Sun, 27 Apr 2025 11:12:26 +0200 Subject: [PATCH 04/15] holy shit minio --- src/main.rs | 8 ++++---- src/nnid/people.rs | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index 49a0513..450e206 100644 --- a/src/main.rs +++ b/src/main.rs @@ -102,19 +102,19 @@ async fn launch() -> _ { .connect(&act_database_url).await .expect("unable to create pool"); - static S3_URL_STRING: Lazy> = Lazy::new(|| + pub static S3_URL_STRING: Lazy> = Lazy::new(|| env::var("S3_URL").expect("S3_URL not specified").into_boxed_str() ); - static S3_URL: Lazy = Lazy::new(|| + pub static S3_URL: Lazy = Lazy::new(|| S3_URL_STRING.parse().unwrap() ); - static S3_USER: Lazy> = Lazy::new(|| + pub static S3_USER: Lazy> = Lazy::new(|| env::var("S3_USER").expect("S3_USER not specified").into_boxed_str() ); - static S3_PASSWD: Lazy> = Lazy::new(|| + pub static S3_PASSWD: Lazy> = Lazy::new(|| env::var("S3_PASSWD").expect("S3_PASSWD not specified").into_boxed_str() ); diff --git a/src/nnid/people.rs b/src/nnid/people.rs index 376a5c6..4cc8cff 100644 --- a/src/nnid/people.rs +++ b/src/nnid/people.rs @@ -31,6 +31,22 @@ const DATABASE_ERROR: Errors = Errors{ ] }; +pub static S3_URL_STRING: Lazy> = Lazy::new(|| + env::var("S3_URL").expect("S3_URL not specified").into_boxed_str() +); + +pub static S3_URL: Lazy = Lazy::new(|| + S3_URL_STRING.parse().unwrap() +); + +pub static S3_USER: Lazy> = Lazy::new(|| + env::var("S3_USER").expect("S3_USER not specified").into_boxed_str() +); + +pub static S3_PASSWD: Lazy> = Lazy::new(|| + env::var("S3_PASSWD").expect("S3_PASSWD not specified").into_boxed_str() +); + fn get_mii_img_url_path(pid: i32, format: &str) -> String{ format!("mii/{}/main.{}", pid, format) } From 820c61143efb41d2116fc423103912525ab5215f Mon Sep 17 00:00:00 2001 From: Andrea Toska Date: Sun, 27 Apr 2025 11:19:05 +0200 Subject: [PATCH 05/15] extra s3 logging --- src/nnid/people.rs | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/src/nnid/people.rs b/src/nnid/people.rs index 4cc8cff..7bb66d2 100644 --- a/src/nnid/people.rs +++ b/src/nnid/people.rs @@ -55,30 +55,44 @@ fn get_mii_img_url(pid: i32, format: &str) -> String{ format!("{}/pn-boss/{}", &*S3_URL_STRING, get_mii_img_url_path(pid, format)) } -async fn generate_s3_images(pid: i32, mii_data: &str){ - - +pub async fn generate_s3_images(pid: i32, mii_data: &str) { let auth = StaticProvider::new(&S3_USER, &S3_PASSWD, None); let Ok(client) = ClientBuilder::new(S3_URL.clone()) .provider(Some(Box::new(auth))) - .build() else { + .build() + else { + println!("Failed to build S3 client for PID {}", pid); return; }; let Some(image) = mii::get_image_png(mii_data).await else { + println!("Failed to fetch PNG image for PID {}", pid); return; }; + let object_name = get_mii_img_url_path(pid, "png"); let object_content = ObjectContent::from(image); - client.put_object_content("pn-cdn", &object_name, object_content).send().await.ok(); + + if let Err(e) = client.put_object_content("pn-cdn", &object_name, object_content).send().await { + println!("Failed to upload PNG for PID {}: {:?}", pid, e); + } else { + println!("Successfully uploaded PNG for PID {}", pid); + } let Some(image) = mii::get_image_tga(mii_data).await else { + println!("Failed to fetch TGA image for PID {}", pid); return; }; - let object_name = get_mii_img_url_path(pid, "tga"); + + let object_name = get_mii_img_url_path(pid, "tga"); let object_content = ObjectContent::from(image); - client.put_object_content("pn-cdn", &object_name, object_content).send().await.ok(); + + if let Err(e) = client.put_object_content("pn-cdn", &object_name, object_content).send().await { + println!("Failed to upload TGA for PID {}: {:?}", pid, e); + } else { + println!("Successfully uploaded TGA for PID {}", pid); + } } #[derive(Deserialize)] From 38c0a6dba1e7929b729d1d785ec717e159bac3fd Mon Sep 17 00:00:00 2001 From: Andrea Toska Date: Sun, 27 Apr 2025 11:26:48 +0200 Subject: [PATCH 06/15] more debugging --- src/nnid/people.rs | 55 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 47 insertions(+), 8 deletions(-) diff --git a/src/nnid/people.rs b/src/nnid/people.rs index 7bb66d2..83c515c 100644 --- a/src/nnid/people.rs +++ b/src/nnid/people.rs @@ -426,23 +426,39 @@ pub async fn change_mii( pub async fn generate_mii_images(client: Arc, bucket: &str, pid: i32, mii_data: &str) { let user_mii_key = format!("mii/{}", pid); + println!("Starting Mii image generation for PID {}", pid); + // Upload normal face images if let Some(png_data) = get_image_png(mii_data).await { + println!("Fetched PNG for PID {}, uploading...", pid); let object_content = ObjectContent::from(png_data.clone()); - let _ = client.put_object_content( + if client.put_object_content( bucket, &format!("{}/normal_face.png", user_mii_key), object_content - ).send().await.ok(); + ).send().await.is_ok() { + println!("Uploaded normal_face.png for PID {}", pid); + } else { + println!("Failed to upload normal_face.png for PID {}", pid); + } + } else { + println!("Failed to fetch PNG for PID {}", pid); } if let Some(tga_data) = get_image_tga(mii_data).await { + println!("Fetched TGA for PID {}, uploading...", pid); let object_content = ObjectContent::from(tga_data.clone()); - let _ = client.put_object_content( + if client.put_object_content( bucket, &format!("{}/standard.tga", user_mii_key), object_content - ).send().await.ok(); + ).send().await.is_ok() { + println!("Uploaded standard.tga for PID {}", pid); + } else { + println!("Failed to upload standard.tga for PID {}", pid); + } + } else { + println!("Failed to fetch TGA for PID {}", pid); } // Upload expressions @@ -456,30 +472,53 @@ pub async fn generate_mii_images(client: Arc, bucket: &str, pid: i32, mi for expression in expressions.iter() { let url = format!("https://mii-unsecure.ariankordi.net/miis/image.png?data={}&expression={}&type=face&width=128&instance_count=1", mii_data, expression); + println!("Fetching expression '{}' for PID {}", expression, pid); if let Ok(resp) = reqwest::get(&url).await { if let Ok(bytes) = resp.bytes().await { + println!("Fetched expression '{}', uploading...", expression); let object_content = ObjectContent::from(bytes.to_vec()); - let _ = client.put_object_content( + if client.put_object_content( bucket, &format!("{}/{}.png", user_mii_key, expression), object_content - ).send().await.ok(); + ).send().await.is_ok() { + println!("Uploaded {}.png for PID {}", expression, pid); + } else { + println!("Failed to upload {}.png for PID {}", expression, pid); + } + } else { + println!("Failed to read bytes for expression '{}' for PID {}", expression, pid); } + } else { + println!("Failed to fetch expression '{}' for PID {}", expression, pid); } } // Upload body let body_url = format!("https://mii-unsecure.ariankordi.net/miis/image.png?data={}&type=all_body&width=270&instance_count=1", mii_data); + println!("Fetching body image for PID {}", pid); if let Ok(resp) = reqwest::get(&body_url).await { if let Ok(bytes) = resp.bytes().await { + println!("Fetched body image, uploading..."); let object_content = ObjectContent::from(bytes.to_vec()); - let _ = client.put_object_content( + if client.put_object_content( bucket, &format!("{}/body.png", user_mii_key), object_content - ).send().await.ok(); + ).send().await.is_ok() { + println!("Uploaded body.png for PID {}", pid); + } else { + println!("Failed to upload body.png for PID {}", pid); + } + } else { + println!("Failed to read body image bytes for PID {}", pid); } + } else { + println!("Failed to fetch body image for PID {}", pid); } + + println!("Finished Mii image generation for PID {}", pid); } + From 981f829f650434a770cd4b4f9a82f8e719278ea4 Mon Sep 17 00:00:00 2001 From: Andrea Toska Date: Sun, 27 Apr 2025 11:29:51 +0200 Subject: [PATCH 07/15] even more debugging --- src/nnid/people.rs | 39 +++++++++++++++++---------------------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/src/nnid/people.rs b/src/nnid/people.rs index 83c515c..512dddc 100644 --- a/src/nnid/people.rs +++ b/src/nnid/people.rs @@ -432,14 +432,13 @@ pub async fn generate_mii_images(client: Arc, bucket: &str, pid: i32, mi if let Some(png_data) = get_image_png(mii_data).await { println!("Fetched PNG for PID {}, uploading...", pid); let object_content = ObjectContent::from(png_data.clone()); - if client.put_object_content( + match client.put_object_content( bucket, &format!("{}/normal_face.png", user_mii_key), object_content - ).send().await.is_ok() { - println!("Uploaded normal_face.png for PID {}", pid); - } else { - println!("Failed to upload normal_face.png for PID {}", pid); + ).send().await { + Ok(_) => println!("Uploaded normal_face.png for PID {}", pid), + Err(e) => println!("Failed to upload normal_face.png for PID {}: {:?}", pid, e), } } else { println!("Failed to fetch PNG for PID {}", pid); @@ -448,20 +447,18 @@ pub async fn generate_mii_images(client: Arc, bucket: &str, pid: i32, mi if let Some(tga_data) = get_image_tga(mii_data).await { println!("Fetched TGA for PID {}, uploading...", pid); let object_content = ObjectContent::from(tga_data.clone()); - if client.put_object_content( + match client.put_object_content( bucket, &format!("{}/standard.tga", user_mii_key), object_content - ).send().await.is_ok() { - println!("Uploaded standard.tga for PID {}", pid); - } else { - println!("Failed to upload standard.tga for PID {}", pid); + ).send().await { + Ok(_) => println!("Uploaded standard.tga for PID {}", pid), + Err(e) => println!("Failed to upload standard.tga for PID {}: {:?}", pid, e), } } else { println!("Failed to fetch TGA for PID {}", pid); } - // Upload expressions let expressions = [ "frustrated", "smile_open_mouth", @@ -478,14 +475,13 @@ pub async fn generate_mii_images(client: Arc, bucket: &str, pid: i32, mi if let Ok(bytes) = resp.bytes().await { println!("Fetched expression '{}', uploading...", expression); let object_content = ObjectContent::from(bytes.to_vec()); - if client.put_object_content( + match client.put_object_content( bucket, &format!("{}/{}.png", user_mii_key, expression), object_content - ).send().await.is_ok() { - println!("Uploaded {}.png for PID {}", expression, pid); - } else { - println!("Failed to upload {}.png for PID {}", expression, pid); + ).send().await { + Ok(_) => println!("Uploaded {}.png for PID {}", expression, pid), + Err(e) => println!("Failed to upload {}.png for PID {}: {:?}", expression, pid, e), } } else { println!("Failed to read bytes for expression '{}' for PID {}", expression, pid); @@ -495,7 +491,6 @@ pub async fn generate_mii_images(client: Arc, bucket: &str, pid: i32, mi } } - // Upload body let body_url = format!("https://mii-unsecure.ariankordi.net/miis/image.png?data={}&type=all_body&width=270&instance_count=1", mii_data); println!("Fetching body image for PID {}", pid); @@ -503,14 +498,13 @@ pub async fn generate_mii_images(client: Arc, bucket: &str, pid: i32, mi if let Ok(bytes) = resp.bytes().await { println!("Fetched body image, uploading..."); let object_content = ObjectContent::from(bytes.to_vec()); - if client.put_object_content( + match client.put_object_content( bucket, &format!("{}/body.png", user_mii_key), object_content - ).send().await.is_ok() { - println!("Uploaded body.png for PID {}", pid); - } else { - println!("Failed to upload body.png for PID {}", pid); + ).send().await { + Ok(_) => println!("Uploaded body.png for PID {}", pid), + Err(e) => println!("Failed to upload body.png for PID {}: {:?}", pid, e), } } else { println!("Failed to read body image bytes for PID {}", pid); @@ -522,3 +516,4 @@ pub async fn generate_mii_images(client: Arc, bucket: &str, pid: i32, mi println!("Finished Mii image generation for PID {}", pid); } + From 1c1aa0b383eb12d7407b400916d06242a97e7be6 Mon Sep 17 00:00:00 2001 From: Andrea Toska Date: Sun, 27 Apr 2025 11:36:14 +0200 Subject: [PATCH 08/15] praying --- src/nnid/people.rs | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/src/nnid/people.rs b/src/nnid/people.rs index 512dddc..9dedd62 100644 --- a/src/nnid/people.rs +++ b/src/nnid/people.rs @@ -1,4 +1,5 @@ use std::env; +use std::io::Cursor; use chrono::{NaiveDate, NaiveDateTime}; use gxhash::{gxhash32, gxhash64}; use minio::s3::builders::{ObjectContent}; @@ -423,30 +424,32 @@ pub async fn change_mii( Ok(()) } +fn build_object_content(data: Vec) -> ObjectContent { + ObjectContent::SegmentedBytes(SegmentedBytes::new_from_bytes(data)) +} + pub async fn generate_mii_images(client: Arc, bucket: &str, pid: i32, mii_data: &str) { let user_mii_key = format!("mii/{}", pid); println!("Starting Mii image generation for PID {}", pid); - // Upload normal face images if let Some(png_data) = get_image_png(mii_data).await { println!("Fetched PNG for PID {}, uploading...", pid); - let object_content = ObjectContent::from(png_data.clone()); + let content = ObjectContent::from(Cursor::new(png_data.clone())); match client.put_object_content( bucket, &format!("{}/normal_face.png", user_mii_key), - object_content + content ).send().await { Ok(_) => println!("Uploaded normal_face.png for PID {}", pid), Err(e) => println!("Failed to upload normal_face.png for PID {}: {:?}", pid, e), } - } else { - println!("Failed to fetch PNG for PID {}", pid); } + if let Some(tga_data) = get_image_tga(mii_data).await { println!("Fetched TGA for PID {}, uploading...", pid); - let object_content = ObjectContent::from(tga_data.clone()); + let object_content = ObjectContent::from(Cursor::new(tga_data.clone())); match client.put_object_content( bucket, &format!("{}/standard.tga", user_mii_key), @@ -468,13 +471,16 @@ pub async fn generate_mii_images(client: Arc, bucket: &str, pid: i32, mi ]; for expression in expressions.iter() { - let url = format!("https://mii-unsecure.ariankordi.net/miis/image.png?data={}&expression={}&type=face&width=128&instance_count=1", mii_data, expression); + let url = format!( + "https://mii-unsecure.ariankordi.net/miis/image.png?data={}&expression={}&type=face&width=128&instance_count=1", + mii_data, expression + ); println!("Fetching expression '{}' for PID {}", expression, pid); if let Ok(resp) = reqwest::get(&url).await { if let Ok(bytes) = resp.bytes().await { println!("Fetched expression '{}', uploading...", expression); - let object_content = ObjectContent::from(bytes.to_vec()); + let object_content = ObjectContent::Bytes(bytes.to_vec()); match client.put_object_content( bucket, &format!("{}/{}.png", user_mii_key, expression), @@ -491,13 +497,16 @@ pub async fn generate_mii_images(client: Arc, bucket: &str, pid: i32, mi } } - let body_url = format!("https://mii-unsecure.ariankordi.net/miis/image.png?data={}&type=all_body&width=270&instance_count=1", mii_data); + let body_url = format!( + "https://mii-unsecure.ariankordi.net/miis/image.png?data={}&type=all_body&width=270&instance_count=1", + mii_data + ); println!("Fetching body image for PID {}", pid); if let Ok(resp) = reqwest::get(&body_url).await { if let Ok(bytes) = resp.bytes().await { println!("Fetched body image, uploading..."); - let object_content = ObjectContent::from(bytes.to_vec()); + let object_content = ObjectContent::Bytes(bytes.to_vec()); match client.put_object_content( bucket, &format!("{}/body.png", user_mii_key), @@ -517,3 +526,4 @@ pub async fn generate_mii_images(client: Arc, bucket: &str, pid: i32, mi } + From ca4354ba0a7958569aff5fdfe7f82c2fca74efaa Mon Sep 17 00:00:00 2001 From: Andrea Toska Date: Sun, 27 Apr 2025 11:39:33 +0200 Subject: [PATCH 09/15] praying again --- src/nnid/people.rs | 82 +++++++++++++++++++++++----------------------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/src/nnid/people.rs b/src/nnid/people.rs index 9dedd62..47dcf03 100644 --- a/src/nnid/people.rs +++ b/src/nnid/people.rs @@ -1,5 +1,6 @@ use std::env; -use std::io::Cursor; +use std::fs; +use std::path::Path; use chrono::{NaiveDate, NaiveDateTime}; use gxhash::{gxhash32, gxhash64}; use minio::s3::builders::{ObjectContent}; @@ -424,39 +425,45 @@ pub async fn change_mii( Ok(()) } -fn build_object_content(data: Vec) -> ObjectContent { - ObjectContent::SegmentedBytes(SegmentedBytes::new_from_bytes(data)) -} - pub async fn generate_mii_images(client: Arc, bucket: &str, pid: i32, mii_data: &str) { let user_mii_key = format!("mii/{}", pid); - println!("Starting Mii image generation for PID {}", pid); - if let Some(png_data) = get_image_png(mii_data).await { - println!("Fetched PNG for PID {}, uploading...", pid); - let content = ObjectContent::from(Cursor::new(png_data.clone())); - match client.put_object_content( - bucket, - &format!("{}/normal_face.png", user_mii_key), - content - ).send().await { - Ok(_) => println!("Uploaded normal_face.png for PID {}", pid), - Err(e) => println!("Failed to upload normal_face.png for PID {}: {:?}", pid, e), - } + async fn save_upload_delete( + client: &Client, + bucket: &str, + key: &str, + data: &[u8], + ) -> Result<(), Box> { + let temp_path = format!("/tmp/{}", key.replace("/", "_")); + fs::write(&temp_path, data)?; + + let content = ObjectContent::from(Path::new(&temp_path)); + client.put_object_content(bucket, key, content).send().await?; + + fs::remove_file(&temp_path)?; + + Ok(()) } + // Upload normal face images + if let Some(png_data) = get_image_png(mii_data).await { + println!("Fetched PNG for PID {}, uploading...", pid); + if let Err(e) = save_upload_delete(&client, bucket, &format!("{}/normal_face.png", user_mii_key), &png_data).await { + println!("Failed to upload normal_face.png for PID {}: {:?}", pid, e); + } else { + println!("Uploaded normal_face.png for PID {}", pid); + } + } else { + println!("Failed to fetch PNG for PID {}", pid); + } if let Some(tga_data) = get_image_tga(mii_data).await { println!("Fetched TGA for PID {}, uploading...", pid); - let object_content = ObjectContent::from(Cursor::new(tga_data.clone())); - match client.put_object_content( - bucket, - &format!("{}/standard.tga", user_mii_key), - object_content - ).send().await { - Ok(_) => println!("Uploaded standard.tga for PID {}", pid), - Err(e) => println!("Failed to upload standard.tga for PID {}: {:?}", pid, e), + if let Err(e) = save_upload_delete(&client, bucket, &format!("{}/standard.tga", user_mii_key), &tga_data).await { + println!("Failed to upload standard.tga for PID {}: {:?}", pid, e); + } else { + println!("Uploaded standard.tga for PID {}", pid); } } else { println!("Failed to fetch TGA for PID {}", pid); @@ -480,14 +487,10 @@ pub async fn generate_mii_images(client: Arc, bucket: &str, pid: i32, mi if let Ok(resp) = reqwest::get(&url).await { if let Ok(bytes) = resp.bytes().await { println!("Fetched expression '{}', uploading...", expression); - let object_content = ObjectContent::Bytes(bytes.to_vec()); - match client.put_object_content( - bucket, - &format!("{}/{}.png", user_mii_key, expression), - object_content - ).send().await { - Ok(_) => println!("Uploaded {}.png for PID {}", expression, pid), - Err(e) => println!("Failed to upload {}.png for PID {}: {:?}", expression, pid, e), + if let Err(e) = save_upload_delete(&client, bucket, &format!("{}/{}.png", user_mii_key, expression), &bytes).await { + println!("Failed to upload {}.png for PID {}: {:?}", expression, pid, e); + } else { + println!("Uploaded {}.png for PID {}", expression, pid); } } else { println!("Failed to read bytes for expression '{}' for PID {}", expression, pid); @@ -506,14 +509,10 @@ pub async fn generate_mii_images(client: Arc, bucket: &str, pid: i32, mi if let Ok(resp) = reqwest::get(&body_url).await { if let Ok(bytes) = resp.bytes().await { println!("Fetched body image, uploading..."); - let object_content = ObjectContent::Bytes(bytes.to_vec()); - match client.put_object_content( - bucket, - &format!("{}/body.png", user_mii_key), - object_content - ).send().await { - Ok(_) => println!("Uploaded body.png for PID {}", pid), - Err(e) => println!("Failed to upload body.png for PID {}: {:?}", pid, e), + if let Err(e) = save_upload_delete(&client, bucket, &format!("{}/body.png", user_mii_key), &bytes).await { + println!("Failed to upload body.png for PID {}: {:?}", pid, e); + } else { + println!("Uploaded body.png for PID {}", pid); } } else { println!("Failed to read body image bytes for PID {}", pid); @@ -527,3 +526,4 @@ pub async fn generate_mii_images(client: Arc, bucket: &str, pid: i32, mi + From a2c8dec604d08155f3f8e04c012422f259a18a30 Mon Sep 17 00:00:00 2001 From: Andrea Toska Date: Sun, 27 Apr 2025 11:41:49 +0200 Subject: [PATCH 10/15] praying again --- src/nnid/people.rs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/nnid/people.rs b/src/nnid/people.rs index 47dcf03..725ac68 100644 --- a/src/nnid/people.rs +++ b/src/nnid/people.rs @@ -1,5 +1,6 @@ use std::env; use std::fs; +use std::io::Write; use std::path::Path; use chrono::{NaiveDate, NaiveDateTime}; use gxhash::{gxhash32, gxhash64}; @@ -436,7 +437,13 @@ pub async fn generate_mii_images(client: Arc, bucket: &str, pid: i32, mi data: &[u8], ) -> Result<(), Box> { let temp_path = format!("/tmp/{}", key.replace("/", "_")); - fs::write(&temp_path, data)?; + + { + use std::fs::File; + let mut file = File::create(&temp_path)?; + file.write_all(data)?; + file.flush()?; + } let content = ObjectContent::from(Path::new(&temp_path)); client.put_object_content(bucket, key, content).send().await?; @@ -446,7 +453,7 @@ pub async fn generate_mii_images(client: Arc, bucket: &str, pid: i32, mi Ok(()) } - // Upload normal face images + // Upload normal face image if let Some(png_data) = get_image_png(mii_data).await { println!("Fetched PNG for PID {}, uploading...", pid); if let Err(e) = save_upload_delete(&client, bucket, &format!("{}/normal_face.png", user_mii_key), &png_data).await { @@ -458,6 +465,7 @@ pub async fn generate_mii_images(client: Arc, bucket: &str, pid: i32, mi println!("Failed to fetch PNG for PID {}", pid); } + // Upload standard TGA if let Some(tga_data) = get_image_tga(mii_data).await { println!("Fetched TGA for PID {}, uploading...", pid); if let Err(e) = save_upload_delete(&client, bucket, &format!("{}/standard.tga", user_mii_key), &tga_data).await { @@ -469,12 +477,13 @@ pub async fn generate_mii_images(client: Arc, bucket: &str, pid: i32, mi println!("Failed to fetch TGA for PID {}", pid); } + // Upload face expressions let expressions = [ "frustrated", "smile_open_mouth", "wink_left", "sorrow", - "surprise_open_mouth" + "surprise_open_mouth", ]; for expression in expressions.iter() { @@ -500,6 +509,7 @@ pub async fn generate_mii_images(client: Arc, bucket: &str, pid: i32, mi } } + // Upload body image let body_url = format!( "https://mii-unsecure.ariankordi.net/miis/image.png?data={}&type=all_body&width=270&instance_count=1", mii_data @@ -527,3 +537,4 @@ pub async fn generate_mii_images(client: Arc, bucket: &str, pid: i32, mi + From f85085b445ec23de4b4c1ab5b1b22819bfea854a Mon Sep 17 00:00:00 2001 From: Andrea Toska Date: Sun, 27 Apr 2025 11:46:07 +0200 Subject: [PATCH 11/15] praying again --- src/nnid/people.rs | 48 ++++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/src/nnid/people.rs b/src/nnid/people.rs index 725ac68..9df9b62 100644 --- a/src/nnid/people.rs +++ b/src/nnid/people.rs @@ -1,5 +1,6 @@ use std::env; use std::fs; +use std::fs::File; use std::io::Write; use std::path::Path; use chrono::{NaiveDate, NaiveDateTime}; @@ -396,7 +397,6 @@ fn build_own_profile(user: User) -> Ds> { )) } - #[put("/v1/api/people/@me/miis/@primary", data = "")] pub async fn change_mii( database: &State, @@ -406,9 +406,10 @@ pub async fn change_mii( ) -> Result<(), Option>> { let db = database.inner(); let pid = auth.pid; - let mii_data = data.data.as_ref(); + println!("Received new Mii data update for PID {}", pid); + let result = sqlx::query!( "UPDATE users SET mii_data = $1 WHERE pid = $2", mii_data, @@ -417,10 +418,13 @@ pub async fn change_mii( .execute(db) .await; - if result.is_err() { + if let Err(e) = result { + println!("Failed to update Mii data for PID {}: {:?}", pid, e); return Err(Some(DATABASE_ERROR)); } + println!("Successfully updated Mii data for PID {}", pid); + generate_mii_images(s3.client.clone(), "pn-cdn", pid, mii_data).await; Ok(()) @@ -430,36 +434,39 @@ pub async fn generate_mii_images(client: Arc, bucket: &str, pid: i32, mi let user_mii_key = format!("mii/{}", pid); println!("Starting Mii image generation for PID {}", pid); - async fn save_upload_delete( + async fn save_and_upload( client: &Client, bucket: &str, key: &str, data: &[u8], ) -> Result<(), Box> { let temp_path = format!("/tmp/{}", key.replace("/", "_")); + println!("Saving temporary file at {}", temp_path); { - use std::fs::File; let mut file = File::create(&temp_path)?; file.write_all(data)?; - file.flush()?; + file.flush()?; // Make sure file is actually written } + println!("File saved, starting upload to S3..."); + let content = ObjectContent::from(Path::new(&temp_path)); client.put_object_content(bucket, key, content).send().await?; - fs::remove_file(&temp_path)?; + println!("Uploaded {} to bucket {}", key, bucket); + + // NOTE: DO NOT delete temp file for now + println!("(Skipping delete for {})", temp_path); Ok(()) } // Upload normal face image if let Some(png_data) = get_image_png(mii_data).await { - println!("Fetched PNG for PID {}, uploading...", pid); - if let Err(e) = save_upload_delete(&client, bucket, &format!("{}/normal_face.png", user_mii_key), &png_data).await { + println!("Fetched PNG for PID {}, preparing upload...", pid); + if let Err(e) = save_and_upload(&client, bucket, &format!("{}/normal_face.png", user_mii_key), &png_data).await { println!("Failed to upload normal_face.png for PID {}: {:?}", pid, e); - } else { - println!("Uploaded normal_face.png for PID {}", pid); } } else { println!("Failed to fetch PNG for PID {}", pid); @@ -467,11 +474,9 @@ pub async fn generate_mii_images(client: Arc, bucket: &str, pid: i32, mi // Upload standard TGA if let Some(tga_data) = get_image_tga(mii_data).await { - println!("Fetched TGA for PID {}, uploading...", pid); - if let Err(e) = save_upload_delete(&client, bucket, &format!("{}/standard.tga", user_mii_key), &tga_data).await { + println!("Fetched TGA for PID {}, preparing upload...", pid); + if let Err(e) = save_and_upload(&client, bucket, &format!("{}/standard.tga", user_mii_key), &tga_data).await { println!("Failed to upload standard.tga for PID {}: {:?}", pid, e); - } else { - println!("Uploaded standard.tga for PID {}", pid); } } else { println!("Failed to fetch TGA for PID {}", pid); @@ -495,11 +500,9 @@ pub async fn generate_mii_images(client: Arc, bucket: &str, pid: i32, mi if let Ok(resp) = reqwest::get(&url).await { if let Ok(bytes) = resp.bytes().await { - println!("Fetched expression '{}', uploading...", expression); - if let Err(e) = save_upload_delete(&client, bucket, &format!("{}/{}.png", user_mii_key, expression), &bytes).await { + println!("Fetched expression '{}', preparing upload...", expression); + if let Err(e) = save_and_upload(&client, bucket, &format!("{}/{}.png", user_mii_key, expression), &bytes).await { println!("Failed to upload {}.png for PID {}: {:?}", expression, pid, e); - } else { - println!("Uploaded {}.png for PID {}", expression, pid); } } else { println!("Failed to read bytes for expression '{}' for PID {}", expression, pid); @@ -518,11 +521,9 @@ pub async fn generate_mii_images(client: Arc, bucket: &str, pid: i32, mi if let Ok(resp) = reqwest::get(&body_url).await { if let Ok(bytes) = resp.bytes().await { - println!("Fetched body image, uploading..."); - if let Err(e) = save_upload_delete(&client, bucket, &format!("{}/body.png", user_mii_key), &bytes).await { + println!("Fetched body image, preparing upload..."); + if let Err(e) = save_and_upload(&client, bucket, &format!("{}/body.png", user_mii_key), &bytes).await { println!("Failed to upload body.png for PID {}: {:?}", pid, e); - } else { - println!("Uploaded body.png for PID {}", pid); } } else { println!("Failed to read body image bytes for PID {}", pid); @@ -538,3 +539,4 @@ pub async fn generate_mii_images(client: Arc, bucket: &str, pid: i32, mi + From 04892e0b1c749be7e8614638226eb8ab828162ae Mon Sep 17 00:00:00 2001 From: Andrea Toska Date: Sun, 27 Apr 2025 11:50:16 +0200 Subject: [PATCH 12/15] delete the files --- src/nnid/people.rs | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/nnid/people.rs b/src/nnid/people.rs index 9df9b62..acd42bc 100644 --- a/src/nnid/people.rs +++ b/src/nnid/people.rs @@ -444,20 +444,22 @@ pub async fn generate_mii_images(client: Arc, bucket: &str, pid: i32, mi println!("Saving temporary file at {}", temp_path); { - let mut file = File::create(&temp_path)?; + let mut file = std::fs::File::create(&temp_path)?; file.write_all(data)?; file.flush()?; // Make sure file is actually written } println!("File saved, starting upload to S3..."); - - let content = ObjectContent::from(Path::new(&temp_path)); + let content = ObjectContent::from(std::path::Path::new(&temp_path)); client.put_object_content(bucket, key, content).send().await?; println!("Uploaded {} to bucket {}", key, bucket); - // NOTE: DO NOT delete temp file for now - println!("(Skipping delete for {})", temp_path); + // ✅ Now delete the temp file + match std::fs::remove_file(&temp_path) { + Ok(_) => println!("Deleted temporary file {}", temp_path), + Err(e) => println!("Failed to delete temporary file {}: {:?}", temp_path, e), + } Ok(()) } @@ -534,9 +536,3 @@ pub async fn generate_mii_images(client: Arc, bucket: &str, pid: i32, mi println!("Finished Mii image generation for PID {}", pid); } - - - - - - From 7696941f194d04d3b1c9000f789e1e4aaf3b00aa Mon Sep 17 00:00:00 2001 From: Andrea Toska Date: Sun, 27 Apr 2025 11:53:00 +0200 Subject: [PATCH 13/15] feat(mii): finally fix mii --- src/nnid/people.rs | 35 ++--------------------------------- 1 file changed, 2 insertions(+), 33 deletions(-) diff --git a/src/nnid/people.rs b/src/nnid/people.rs index acd42bc..71a2b05 100644 --- a/src/nnid/people.rs +++ b/src/nnid/people.rs @@ -432,7 +432,6 @@ pub async fn change_mii( pub async fn generate_mii_images(client: Arc, bucket: &str, pid: i32, mii_data: &str) { let user_mii_key = format!("mii/{}", pid); - println!("Starting Mii image generation for PID {}", pid); async fn save_and_upload( client: &Client, @@ -441,50 +440,33 @@ pub async fn generate_mii_images(client: Arc, bucket: &str, pid: i32, mi data: &[u8], ) -> Result<(), Box> { let temp_path = format!("/tmp/{}", key.replace("/", "_")); - println!("Saving temporary file at {}", temp_path); { let mut file = std::fs::File::create(&temp_path)?; file.write_all(data)?; - file.flush()?; // Make sure file is actually written + file.flush()?; } - println!("File saved, starting upload to S3..."); let content = ObjectContent::from(std::path::Path::new(&temp_path)); client.put_object_content(bucket, key, content).send().await?; - println!("Uploaded {} to bucket {}", key, bucket); - - // ✅ Now delete the temp file - match std::fs::remove_file(&temp_path) { - Ok(_) => println!("Deleted temporary file {}", temp_path), - Err(e) => println!("Failed to delete temporary file {}: {:?}", temp_path, e), - } + std::fs::remove_file(&temp_path)?; Ok(()) } - // Upload normal face image if let Some(png_data) = get_image_png(mii_data).await { - println!("Fetched PNG for PID {}, preparing upload...", pid); if let Err(e) = save_and_upload(&client, bucket, &format!("{}/normal_face.png", user_mii_key), &png_data).await { println!("Failed to upload normal_face.png for PID {}: {:?}", pid, e); } - } else { - println!("Failed to fetch PNG for PID {}", pid); } - // Upload standard TGA if let Some(tga_data) = get_image_tga(mii_data).await { - println!("Fetched TGA for PID {}, preparing upload...", pid); if let Err(e) = save_and_upload(&client, bucket, &format!("{}/standard.tga", user_mii_key), &tga_data).await { println!("Failed to upload standard.tga for PID {}: {:?}", pid, e); } - } else { - println!("Failed to fetch TGA for PID {}", pid); } - // Upload face expressions let expressions = [ "frustrated", "smile_open_mouth", @@ -498,40 +480,27 @@ pub async fn generate_mii_images(client: Arc, bucket: &str, pid: i32, mi "https://mii-unsecure.ariankordi.net/miis/image.png?data={}&expression={}&type=face&width=128&instance_count=1", mii_data, expression ); - println!("Fetching expression '{}' for PID {}", expression, pid); if let Ok(resp) = reqwest::get(&url).await { if let Ok(bytes) = resp.bytes().await { - println!("Fetched expression '{}', preparing upload...", expression); if let Err(e) = save_and_upload(&client, bucket, &format!("{}/{}.png", user_mii_key, expression), &bytes).await { println!("Failed to upload {}.png for PID {}: {:?}", expression, pid, e); } - } else { - println!("Failed to read bytes for expression '{}' for PID {}", expression, pid); } - } else { - println!("Failed to fetch expression '{}' for PID {}", expression, pid); } } - // Upload body image let body_url = format!( "https://mii-unsecure.ariankordi.net/miis/image.png?data={}&type=all_body&width=270&instance_count=1", mii_data ); - println!("Fetching body image for PID {}", pid); if let Ok(resp) = reqwest::get(&body_url).await { if let Ok(bytes) = resp.bytes().await { - println!("Fetched body image, preparing upload..."); if let Err(e) = save_and_upload(&client, bucket, &format!("{}/body.png", user_mii_key), &bytes).await { println!("Failed to upload body.png for PID {}: {:?}", pid, e); } - } else { - println!("Failed to read body image bytes for PID {}", pid); } - } else { - println!("Failed to fetch body image for PID {}", pid); } println!("Finished Mii image generation for PID {}", pid); From 2f42185b7f46cbaae2b998937142064e3adb8be2 Mon Sep 17 00:00:00 2001 From: Andrea Toska Date: Sun, 27 Apr 2025 11:55:47 +0200 Subject: [PATCH 14/15] feat(mii): make S3 bucket in env --- src/nnid/people.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/nnid/people.rs b/src/nnid/people.rs index 71a2b05..9de450d 100644 --- a/src/nnid/people.rs +++ b/src/nnid/people.rs @@ -51,6 +51,10 @@ pub static S3_PASSWD: Lazy> = Lazy::new(|| env::var("S3_PASSWD").expect("S3_PASSWD not specified").into_boxed_str() ); +pub static S3_BUCKET: Lazy> = Lazy::new(|| + env::var("S3_BUCKET").expect("S3_BUCKET not specified").into_boxed_str() +); + fn get_mii_img_url_path(pid: i32, format: &str) -> String{ format!("mii/{}/main.{}", pid, format) } @@ -78,7 +82,7 @@ pub async fn generate_s3_images(pid: i32, mii_data: &str) { let object_name = get_mii_img_url_path(pid, "png"); let object_content = ObjectContent::from(image); - if let Err(e) = client.put_object_content("pn-cdn", &object_name, object_content).send().await { + if let Err(e) = client.put_object_content(&**S3_BUCKET, &object_name, object_content).send().await { println!("Failed to upload PNG for PID {}: {:?}", pid, e); } else { println!("Successfully uploaded PNG for PID {}", pid); @@ -92,7 +96,7 @@ pub async fn generate_s3_images(pid: i32, mii_data: &str) { let object_name = get_mii_img_url_path(pid, "tga"); let object_content = ObjectContent::from(image); - if let Err(e) = client.put_object_content("pn-cdn", &object_name, object_content).send().await { + if let Err(e) = client.put_object_content(&**S3_BUCKET, &object_name, object_content).send().await { println!("Failed to upload TGA for PID {}: {:?}", pid, e); } else { println!("Successfully uploaded TGA for PID {}", pid); @@ -425,7 +429,7 @@ pub async fn change_mii( println!("Successfully updated Mii data for PID {}", pid); - generate_mii_images(s3.client.clone(), "pn-cdn", pid, mii_data).await; + generate_mii_images(s3.client.clone(), &**S3_BUCKET, pid, mii_data).await; Ok(()) } From a019b36d5df40eee9cb48c889d7ea7e8d25aa261 Mon Sep 17 00:00:00 2001 From: Andrea Toska Date: Sun, 27 Apr 2025 13:02:03 +0200 Subject: [PATCH 15/15] re-stub email verification --- src/nnid/support.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/nnid/support.rs b/src/nnid/support.rs index 439aeac..d3e1a5d 100644 --- a/src/nnid/support.rs +++ b/src/nnid/support.rs @@ -20,9 +20,7 @@ pub struct ValidateEmailInput{ } #[post("/v1/api/support/validate/email", data="")] pub async fn validate(data: Form){ - if let Err(e) = send_verification_email(&data.email, 123456, "Andrea Test Username").await { - println!("Failed to send verification email: {e}"); - } + } #[put("/v1/api/support/email_confirmation//")]