A LOT of stuff
All checks were successful
Build and Test / account (push) Successful in 7m48s

Basically I removed all the warnings, removed some old APIs no longer in use, added cert verification to DB, im just cool like that.
This commit is contained in:
red binder 2026-04-27 16:37:54 +02:00
commit 5a8e61c255
18 changed files with 363 additions and 254 deletions

View file

@ -1,6 +1,5 @@
use std::{env, io};
use std::collections::HashSet;
use gxhash::HashMap;
use once_cell::sync::Lazy;
use rocket::fs::NamedFile;
use rocket::{get, Request};

View file

@ -6,7 +6,7 @@ use std::io::Cursor;
use rocket::{Request, response::{Responder, Response}};
use rocket::http::Header;
use time::{OffsetDateTime, Time};
use time::OffsetDateTime;
use time::format_description::well_known::Rfc2822;
#[derive(Serialize)]

View file

@ -1,3 +1,4 @@
#![allow(unused)]
use rocket::{post, FromForm, State};
use rocket::form::Form;
use serde::{Serialize};

View file

@ -1,3 +1,4 @@
#![allow(unused)]
use chrono::{NaiveDate, NaiveDateTime};
use gxhash::{gxhash32, gxhash64};
use rocket::{get, post, put, State};
@ -73,8 +74,8 @@ pub struct Email{
#[derive(Deserialize)]
pub struct UpdateMiiData {
name: Box<str>,
primary: crate::xml::YesNoVal,
_name: Box<str>,
_primary: crate::xml::YesNoVal,
data: Box<str>,
}
@ -109,7 +110,7 @@ pub struct AccountCreationResponseData{
}
#[post("/v1/api/people", data="<data>")]
pub async fn create_account(database: &State<Pool>, data: Xml<AccountCreationData>) -> Result<Xml<AccountCreationResponseData>, Option<Errors>>{
pub async fn create_account(database: &State<Pool>, data: Xml<AccountCreationData>) -> Result<Xml<AccountCreationResponseData>, Option<Errors<'_>>>{
let database = database.inner();
// its fine to crash here if we cant get the next pid as that is in my opinion a dead state

View file

@ -1,6 +1,7 @@
use crate::Pool;
use crate::error::{Error, Errors};
use chrono::Utc;
use hickory_resolver::TokioAsyncResolver;
use rocket::form::Form;
use rocket::{FromForm, State, post, put};
@ -15,8 +16,58 @@ const BAD_CODE_ERROR: Errors = Errors {
pub struct ValidateEmailInput {
email: String,
}
#[post("/v1/api/support/validate/email", data = "<data>")]
pub async fn validate(data: Form<ValidateEmailInput>) {}
pub async fn validate(
data: Form<ValidateEmailInput>,
) -> Result<(), Errors<'static>> {
let email = data.email.trim();
// 1. Validate presence + basic format
if email.is_empty() || !email.contains('@') {
return Err(Errors {
error: &[Error {
code: "0103",
message: "Email format is invalid",
}],
});
}
// 2. Extract domain safely
let domain = match email.split('@').nth(1) {
Some(d) if !d.is_empty() => d,
_ => {
return Err(Errors {
error: &[Error {
code: "0103",
message: "Email format is invalid",
}],
});
}
};
// 3. DNS resolver
let resolver = TokioAsyncResolver::tokio_from_system_conf()
.map_err(|_| Errors {
error: &[Error {
code: "1126",
message: "DNS resolver initialization failed",
}],
})?;
// 4. MX lookup
match resolver.mx_lookup(domain).await {
Ok(mx) if mx.iter().next().is_some() => Ok(()),
_ => Err(Errors {
error: &[Error {
code: "1126",
message: "The domain is not accessible",
}],
}),
}
}
#[put("/v1/api/support/email_confirmation/<pid>/<code>")]
pub async fn verify_email(