From be7e9e385078d6e0fe314aab7cd01d24d0289e90 Mon Sep 17 00:00:00 2001 From: sargon64 Date: Wed, 26 Jul 2023 20:55:56 -0700 Subject: [PATCH] fix: remove unused data extractor --- .../src/m20230727_015400_load_default_data.rs | 45 ------------------- src/main.rs | 1 - src/mods.rs | 7 +-- src/users.rs | 7 ++- 4 files changed, 7 insertions(+), 53 deletions(-) diff --git a/migration/src/m20230727_015400_load_default_data.rs b/migration/src/m20230727_015400_load_default_data.rs index 2757083..80ae702 100644 --- a/migration/src/m20230727_015400_load_default_data.rs +++ b/migration/src/m20230727_015400_load_default_data.rs @@ -1,51 +1,6 @@ use sea_orm_migration::{prelude::*, sea_orm::{Set, TransactionTrait, ActiveModelTrait, EntityTrait, ColumnTrait, QueryFilter}}; use entity::{prelude::*, beat_saber_versions, categories}; -//INSERT INTO beat_saber_versions VALUES (DEFAULT, '1.31.0'); -// INSERT INTO beat_saber_versions VALUES (DEFAULT, '1.30.2'); -// INSERT INTO beat_saber_versions VALUES (DEFAULT, '1.30.0'); -// INSERT INTO beat_saber_versions VALUES (DEFAULT, '1.29.4'); -// INSERT INTO beat_saber_versions VALUES (DEFAULT, '1.26.0'); -// INSERT INTO beat_saber_versions VALUES (DEFAULT, '1.29.0'); -// INSERT INTO beat_saber_versions VALUES (DEFAULT, '1.28.0'); -// INSERT INTO beat_saber_versions VALUES (DEFAULT, '1.27.0'); -// INSERT INTO beat_saber_versions VALUES (DEFAULT, '1.26.2'); -// INSERT INTO beat_saber_versions VALUES (DEFAULT, '1.26.1'); -// INSERT INTO beat_saber_versions VALUES (DEFAULT, '1.21.0'); -// INSERT INTO beat_saber_versions VALUES (DEFAULT, '1.20.0'); -// INSERT INTO beat_saber_versions VALUES (DEFAULT, '1.19.0'); -// INSERT INTO beat_saber_versions VALUES (DEFAULT, '1.18.0'); -// INSERT INTO beat_saber_versions VALUES (DEFAULT, '1.17.0'); -// INSERT INTO beat_saber_versions VALUES (DEFAULT, '1.16.3'); -// INSERT INTO beat_saber_versions VALUES (DEFAULT, '1.16.1'); -// INSERT INTO beat_saber_versions VALUES (DEFAULT, '1.13.4'); -// INSERT INTO beat_saber_versions VALUES (DEFAULT, '1.13.2'); -// INSERT INTO beat_saber_versions VALUES (DEFAULT, '1.12.2'); -// INSERT INTO beat_saber_versions VALUES (DEFAULT, '1.11.0'); -// INSERT INTO beat_saber_versions VALUES (DEFAULT, '1.8.0'); -// INSERT INTO beat_saber_versions VALUES (DEFAULT, '1.6.1'); -// INSERT INTO beat_saber_versions VALUES (DEFAULT, '1.6.0'); -// INSERT INTO beat_saber_versions VALUES (DEFAULT, '1.5.0'); -// INSERT INTO beat_saber_versions VALUES (DEFAULT, '1.3.0'); -// INSERT INTO beat_saber_versions VALUES (DEFAULT, '1.1.1'); -// INSERT INTO beat_saber_versions VALUES (DEFAULT, '1.1.0'); -// INSERT INTO beat_saber_versions VALUES (DEFAULT, '1.0.0'); -// INSERT INTO beat_saber_versions VALUES (DEFAULT, '0.13.2'); - -//INSERT INTO categories VALUES (DEFAULT, 'core', 'Mods that only depend on other core mods.'); -// INSERT INTO categories VALUES (DEFAULT, 'libraries', 'Mods that are used by other mods.'); -// INSERT INTO categories VALUES (DEFAULT, 'cosmetic', 'Mods that affect the appearance of the game.'); -// INSERT INTO categories VALUES (DEFAULT, 'gameplay', 'Mods that affect gameplay.'); -// INSERT INTO categories VALUES (DEFAULT, 'leaderboards', 'Mods that affect leaderboards.'); -// INSERT INTO categories VALUES (DEFAULT, 'lighting', 'Mods that affect lighting.'); -// INSERT INTO categories VALUES (DEFAULT, 'multiplayer', 'Mods that change online play.'); -// INSERT INTO categories VALUES (DEFAULT, 'accessibility', 'Mods that affect accessibility.'); -// INSERT INTO categories VALUES (DEFAULT, 'practice', 'Mods that are used for practice.'); -// INSERT INTO categories VALUES (DEFAULT, 'streaming', 'Mods that affect live streams.'); -// INSERT INTO categories VALUES (DEFAULT, 'text', 'Mods that change how text is displayed.'); -// INSERT INTO categories VALUES (DEFAULT, 'tweaks', 'Mods that tweak the gameplay experience.'); -// INSERT INTO categories VALUES (DEFAULT, 'ui', 'Mods that affect the ui.'); -// INSERT INTO categories VALUES (DEFAULT, 'other', 'Mods that do not fit into other categories.'); const BEAT_SABER_VERSIONS: [&'static str; 30] = [ "1.31.0", "1.30.2", diff --git a/src/main.rs b/src/main.rs index edcc49e..28a42c4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -90,7 +90,6 @@ async fn main() -> io::Result<()> { HttpServer::new( move || { App::new() .app_data(Data::new(create_schema())) - .app_data(Data::new(KEY.clone())) .app_data(Data::new(Database { pool: db_conn.clone(), })) diff --git a/src/mods.rs b/src/mods.rs index 27ee2e3..c0d8f5d 100644 --- a/src/mods.rs +++ b/src/mods.rs @@ -1,3 +1,4 @@ +use actix_web::{web, Responder, HttpRequest, post, HttpResponse}; use chrono::{DateTime, Utc}; use forge_lib::structs::forgemod::ForgeMod; use juniper::{FieldError, FieldResult, GraphQLObject}; @@ -108,7 +109,7 @@ pub async fn find_by_author(db: &Database, author: Uuid) -> FieldResult Ok(futures::future::join_all(mods).await) } -pub async fn new_mod(db: &Database, forgemod: ForgeMod) -> FieldResult { - - todo!() +#[post("/mods")] +pub async fn create_mod(db: web::Data, payload: web::Payload, req: HttpRequest) -> impl Responder { + HttpResponse::Ok().body("Hello world!") } \ No newline at end of file diff --git a/src/users.rs b/src/users.rs index c74183d..185f065 100644 --- a/src/users.rs +++ b/src/users.rs @@ -12,7 +12,7 @@ use uuid::Uuid; use crate::{ auth::{self, validate_permissions, Authorization, JWTAuth, Permission}, mods::{self, Mod}, - Database, Key, + Database, Key, KEY, }; #[derive(GraphQLObject, Debug, Deserialize, Serialize)] @@ -152,7 +152,6 @@ pub struct UserAuthReq { pub async fn user_auth( req: HttpRequest, data: web::Data, - key: web::Data, info: web::Query, ) -> impl Responder { let code = &info.code; @@ -166,7 +165,7 @@ pub async fn user_auth( })) .unwrap() .send() - .unwrap(); //.json::().unwrap()["access_token"].to_string(); + .unwrap(); let gat = gat.as_str().unwrap().split("&").collect::>()[0] .split("=") .collect::>()[1] @@ -207,7 +206,7 @@ pub async fn user_auth( .unwrap() .unwrap(); - let jwt = JWTAuth::new(user).encode(**key); + let jwt = JWTAuth::new(user).encode(*KEY.clone()); let mut res = HttpResponse::Ok(); res.cookie(