From 5054353e1de338ccad215ebd6168d4df23c6d6ce Mon Sep 17 00:00:00 2001 From: Igor Bubelov Date: Thu, 5 Sep 2024 12:50:30 +0700 Subject: [PATCH] Refactor RPC --- src/area/mod.rs | 1 - src/rpc/mod.rs | 1 + src/{area/rpc.rs => rpc/remove_area.rs} | 11 ++++------- src/server/mod.rs | 2 +- 4 files changed, 6 insertions(+), 9 deletions(-) rename src/{area/rpc.rs => rpc/remove_area.rs} (79%) diff --git a/src/area/mod.rs b/src/area/mod.rs index fe97e7f..c9fcd49 100644 --- a/src/area/mod.rs +++ b/src/area/mod.rs @@ -1,7 +1,6 @@ pub mod model; pub use model::Area; pub mod admin; -pub mod rpc; pub mod service; pub mod v2; pub mod v3; diff --git a/src/rpc/mod.rs b/src/rpc/mod.rs index 354f0a7..086cc93 100644 --- a/src/rpc/mod.rs +++ b/src/rpc/mod.rs @@ -5,5 +5,6 @@ pub mod generate_element_issues; pub mod get_area; pub mod get_trending_communities; pub mod get_trending_countries; +pub mod remove_area; pub mod remove_area_tag; pub mod set_area_tag; diff --git a/src/area/rpc.rs b/src/rpc/remove_area.rs similarity index 79% rename from src/area/rpc.rs rename to src/rpc/remove_area.rs index 6364d71..49052e0 100644 --- a/src/area/rpc.rs +++ b/src/rpc/remove_area.rs @@ -1,6 +1,6 @@ -use super::Area; +use crate::area::Area; use crate::Result; -use crate::{area, auth::Token, discord, Error}; +use crate::{area, auth::Token, discord}; use deadpool_sqlite::Pool; use jsonrpc_v2::{Data, Params}; use serde::Deserialize; @@ -8,15 +8,12 @@ use std::sync::Arc; use tracing::info; #[derive(Deserialize)] -pub struct RemoveArgs { +pub struct Args { pub token: String, pub id: String, } -pub async fn remove( - Params(args): Params, - pool: Data>, -) -> Result { +pub async fn run(Params(args): Params, pool: Data>) -> Result { let token = pool .get() .await? diff --git a/src/server/mod.rs b/src/server/mod.rs index 7bbe321..81fcacb 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -93,7 +93,7 @@ pub async fn run() -> Result<()> { .with_method("removeareatag", rpc::remove_area_tag::run) .with_method("gettrendingcountries", rpc::get_trending_countries::run) .with_method("gettrendingcommunities", rpc::get_trending_communities::run) - .with_method("removearea", area::rpc::remove) + .with_method("removearea", rpc::remove_area::run) .finish() .into_actix_web_service(), ),