-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
40 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
use crate::{area, discord, Error}; | ||
use crate::{area::Area, auth::Token}; | ||
use deadpool_sqlite::Pool; | ||
use jsonrpc_v2::{Data, Params}; | ||
use serde::Deserialize; | ||
use serde_json::{Map, Value}; | ||
use std::sync::Arc; | ||
use tracing::info; | ||
|
||
#[derive(Deserialize)] | ||
pub struct Args { | ||
pub token: String, | ||
pub tags: Map<String, Value>, | ||
} | ||
|
||
pub async fn run(Params(args): Params<Args>, pool: Data<Arc<Pool>>) -> Result<Area, Error> { | ||
let token = pool | ||
.get() | ||
.await? | ||
.interact(move |conn| Token::select_by_secret(&args.token, conn)) | ||
.await?? | ||
.unwrap(); | ||
let area = pool | ||
.get() | ||
.await? | ||
.interact(move |conn| area::service::insert(args.tags, conn)) | ||
.await??; | ||
let log_message = format!( | ||
"{} created area {} https://api.btcmap.org/v3/areas/{}", | ||
token.owner, | ||
area.name(), | ||
area.id, | ||
); | ||
info!(log_message); | ||
discord::send_message_to_channel(&log_message, discord::CHANNEL_API).await; | ||
Ok(area) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
pub mod add_area; | ||
pub mod add_element_comment; | ||
pub mod boost_element; | ||
pub mod generate_element_issues; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters