webhooks
This commit is contained in:
parent
37475460e2
commit
02966c0605
9 changed files with 340 additions and 13 deletions
|
@ -1,10 +1,11 @@
|
|||
use mongod::ToAPI;
|
||||
use rocket::serde::json::Json;
|
||||
use rocket::{get, post, State};
|
||||
use serde::Deserialize;
|
||||
use serde_json::json;
|
||||
|
||||
use crate::check_auth;
|
||||
use crate::config::Config;
|
||||
use crate::config::{Config, Webhook};
|
||||
use crate::routes::Token;
|
||||
use crate::{
|
||||
db::ItemDB,
|
||||
|
@ -38,7 +39,7 @@ pub async fn supply_route(
|
|||
.variant(&form.variant)
|
||||
.ok_or_else(variant_does_not_exist_error)?;
|
||||
|
||||
let transaction_id = variant
|
||||
let transaction = variant
|
||||
.supply(
|
||||
form.price
|
||||
.clone()
|
||||
|
@ -49,7 +50,13 @@ pub async fn supply_route(
|
|||
)
|
||||
.await;
|
||||
|
||||
Ok(json!({"uuid": transaction_id}))
|
||||
if let Some(hook) = &c.webhook {
|
||||
if let Some(url) = &hook.transaction_added {
|
||||
Webhook::send(url, &transaction.api().await).await;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(json!({"uuid": transaction._id}))
|
||||
}
|
||||
|
||||
/// Returns a list of Transaction UUIDs for the Item Variant
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue