Przeglądaj źródła

wip creating user creation route.

Lee Morgan 2 miesięcy temu
rodzic
commit
c1e16d335c
3 zmienionych plików z 20 dodań i 1 usunięć
  1. 1 0
      Cargo.lock
  2. 1 0
      Cargo.toml
  3. 18 1
      src/controllers/user/create.rs

+ 1 - 0
Cargo.lock

@@ -899,6 +899,7 @@ dependencies = [
  "actix-web",
  "chrono",
  "serde",
+ "serde_json",
  "sqlx",
  "thiserror",
  "uuid",

+ 1 - 0
Cargo.toml

@@ -7,6 +7,7 @@ edition = "2024"
 actix-web = "4.13.0"
 chrono = "0.4.44"
 serde = "1.0.228"
+serde_json = "1.0.149"
 sqlx = "0.8.6"
 thiserror = "2.0.18"
 uuid = "1.23.1"

+ 18 - 1
src/controllers/user/create.rs

@@ -1,5 +1,6 @@
 use actix_web::{HttpResponse, web, post};
 use serde::Serialize;
+use serde_json::json;
 use sqlx::{PgPool, types::Uuid};
 use crate::{
     app_error::AppError
@@ -19,5 +20,21 @@ pub async fn route(
     db: web::Data<PgPool>,
     body: web::Json<Body>
 ) -> Result<HttpResponse, AppError> {
-    
+    let email = body.email.to_lowercase();
+    if is_bot(&body.url, &body.time) {
+        return Ok(HttpResponse::Ok().json(json!("success": true))));
+    }
+}
+
+fn is_bot(url: &Option<String>, time: &Option<String>) -> bool {
+    match url {
+        Some(u) => {
+            if url != "https://" {return true}
+        },
+        None => {return true}
+    }
+
+    match time {
+        Some(t) => match DateTime::
+    }
 }