-
-
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
8 changed files
with
133 additions
and
120 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
pub mod model; | ||
pub use model::Element; | ||
pub mod admin; | ||
pub mod rpc; | ||
pub mod service; | ||
pub mod v2; | ||
pub mod v3; |
This file was deleted.
Oops, something went wrong.
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,27 @@ | ||
use crate::Result; | ||
use crate::{auth::Token, element::model::Element}; | ||
use deadpool_sqlite::Pool; | ||
use jsonrpc_v2::{Data, Params}; | ||
use serde::Deserialize; | ||
use std::sync::Arc; | ||
|
||
#[derive(Deserialize)] | ||
pub struct Args { | ||
pub token: String, | ||
pub id: String, | ||
} | ||
|
||
pub async fn run(Params(args): Params<Args>, pool: Data<Arc<Pool>>) -> Result<Element> { | ||
pool.get() | ||
.await? | ||
.interact(move |conn| Token::select_by_secret(&args.token, conn)) | ||
.await?? | ||
.unwrap(); | ||
let element = pool | ||
.get() | ||
.await? | ||
.interact(move |conn| Element::select_by_id_or_osm_id(&args.id, conn)) | ||
.await?? | ||
.unwrap(); | ||
Ok(element) | ||
} |
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,46 @@ | ||
use crate::discord; | ||
use crate::Result; | ||
use crate::{auth::Token, element::model::Element}; | ||
use deadpool_sqlite::Pool; | ||
use jsonrpc_v2::{Data, Params}; | ||
use serde::Deserialize; | ||
use std::sync::Arc; | ||
use tracing::info; | ||
|
||
#[derive(Deserialize)] | ||
pub struct Args { | ||
pub token: String, | ||
pub id: String, | ||
pub tag: String, | ||
} | ||
|
||
pub async fn run(Params(args): Params<Args>, pool: Data<Arc<Pool>>) -> Result<Element> { | ||
let token = pool | ||
.get() | ||
.await? | ||
.interact(move |conn| Token::select_by_secret(&args.token, conn)) | ||
.await?? | ||
.unwrap(); | ||
let element = pool | ||
.get() | ||
.await? | ||
.interact(move |conn| Element::select_by_id_or_osm_id(&args.id, conn)) | ||
.await?? | ||
.unwrap(); | ||
let cloned_tag = args.tag.clone(); | ||
let element = pool | ||
.get() | ||
.await? | ||
.interact(move |conn| Element::remove_tag(element.id, &cloned_tag, conn)) | ||
.await??; | ||
let log_message = format!( | ||
"{} removed tag {} from element {} https://api.btcmap.org/v3/elements/{}", | ||
token.owner, | ||
args.tag, | ||
element.name(), | ||
element.id, | ||
); | ||
info!(log_message); | ||
discord::send_message_to_channel(&log_message, discord::CHANNEL_API).await; | ||
Ok(element) | ||
} |
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,50 @@ | ||
use crate::discord; | ||
use crate::Result; | ||
use crate::{auth::Token, element::model::Element}; | ||
use deadpool_sqlite::Pool; | ||
use jsonrpc_v2::{Data, Params}; | ||
use serde::Deserialize; | ||
use serde_json::Value; | ||
use std::sync::Arc; | ||
use tracing::info; | ||
|
||
#[derive(Deserialize)] | ||
pub struct Args { | ||
pub token: String, | ||
pub id: String, | ||
pub name: String, | ||
pub value: Value, | ||
} | ||
|
||
pub async fn run(Params(args): Params<Args>, pool: Data<Arc<Pool>>) -> Result<Element> { | ||
let token = pool | ||
.get() | ||
.await? | ||
.interact(move |conn| Token::select_by_secret(&args.token, conn)) | ||
.await?? | ||
.unwrap(); | ||
let element = pool | ||
.get() | ||
.await? | ||
.interact(move |conn| Element::select_by_id_or_osm_id(&args.id, conn)) | ||
.await?? | ||
.unwrap(); | ||
let cloned_name = args.name.clone(); | ||
let cloned_value = args.value.clone(); | ||
let element = pool | ||
.get() | ||
.await? | ||
.interact(move |conn| Element::set_tag(element.id, &cloned_name, &cloned_value, conn)) | ||
.await??; | ||
let log_message = format!( | ||
"{} set tag {} = {} for element {} https://api.btcmap.org/v3/elements/{}", | ||
token.owner, | ||
args.name, | ||
serde_json::to_string(&args.value)?, | ||
element.name(), | ||
element.id, | ||
); | ||
info!(log_message); | ||
discord::send_message_to_channel(&log_message, discord::CHANNEL_API).await; | ||
Ok(element) | ||
} |
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