Skip to content

Commit

Permalink
Refactor RPC
Browse files Browse the repository at this point in the history
  • Loading branch information
bubelov committed Sep 5, 2024
1 parent 486fcd5 commit 5054353
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 9 deletions.
1 change: 0 additions & 1 deletion src/area/mod.rs
Original file line number Diff line number Diff line change
@@ -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;
1 change: 1 addition & 0 deletions src/rpc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
11 changes: 4 additions & 7 deletions src/area/rpc.rs → src/rpc/remove_area.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
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;
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<RemoveArgs>,
pool: Data<Arc<Pool>>,
) -> Result<Area, Error> {
pub async fn run(Params(args): Params<Args>, pool: Data<Arc<Pool>>) -> Result<Area> {
let token = pool
.get()
.await?
Expand Down
2 changes: 1 addition & 1 deletion src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
),
Expand Down

0 comments on commit 5054353

Please sign in to comment.