mirror of
https://github.com/modrinth/code.git
synced 2026-09-03 13:36:48 +00:00
@@ -36,8 +36,9 @@ struct TiltifyWebhook {
|
|||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, utoipa::ToSchema)]
|
#[derive(Debug, Serialize, Deserialize, utoipa::ToSchema)]
|
||||||
struct TiltifyData {
|
struct TiltifyData {
|
||||||
amount_raised: AmountRaised,
|
amount: AmountRaised,
|
||||||
user: TiltifyUser,
|
donor_name: String,
|
||||||
|
completed_at: DateTime<Utc>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, utoipa::ToSchema)]
|
#[derive(Debug, Serialize, Deserialize, utoipa::ToSchema)]
|
||||||
@@ -46,12 +47,6 @@ struct AmountRaised {
|
|||||||
value: Decimal,
|
value: Decimal,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, utoipa::ToSchema)]
|
|
||||||
struct TiltifyUser {
|
|
||||||
id: Uuid,
|
|
||||||
username: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, utoipa::ToSchema)]
|
#[derive(Debug, Serialize, Deserialize, utoipa::ToSchema)]
|
||||||
struct TiltifyMeta {
|
struct TiltifyMeta {
|
||||||
attempted_at: DateTime<Utc>,
|
attempted_at: DateTime<Utc>,
|
||||||
@@ -168,14 +163,14 @@ pub async fn tiltify_webhook(
|
|||||||
id,
|
id,
|
||||||
tiltify_event_id: payload.meta.id,
|
tiltify_event_id: payload.meta.id,
|
||||||
raw_data: raw_payload,
|
raw_data: raw_payload,
|
||||||
donated_at: payload.meta.generated_at,
|
donated_at: payload.data.completed_at,
|
||||||
amount_usd: None,
|
amount_usd: None,
|
||||||
user_id: None,
|
user_id: None,
|
||||||
};
|
};
|
||||||
|
|
||||||
let username = async {
|
let username = async {
|
||||||
// then we can attempt user lookups
|
// then we can attempt user lookups
|
||||||
let username = payload.data.user.username;
|
let username = payload.data.donor_name.clone();
|
||||||
let user = DBUser::get(&username, &**pool, &redis)
|
let user = DBUser::get(&username, &**pool, &redis)
|
||||||
.await
|
.await
|
||||||
.wrap_err("fetching user from database")?
|
.wrap_err("fetching user from database")?
|
||||||
@@ -195,7 +190,7 @@ pub async fn tiltify_webhook(
|
|||||||
let amount_usd = async {
|
let amount_usd = async {
|
||||||
// and insert value amount
|
// and insert value amount
|
||||||
let amount_usd =
|
let amount_usd =
|
||||||
amount_raised_usd(&payload.data.amount_raised, &payouts_queue)
|
amount_raised_usd(&payload.data.amount, &payouts_queue)
|
||||||
.await
|
.await
|
||||||
.wrap_err("failed to get donation amount")?;
|
.wrap_err("failed to get donation amount")?;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user