mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-14 13:52:11 +00:00
compile errors
This commit is contained in:
1 parent
e5f1cd00ef
commit
aef0c2f76a
3 files changed
+37
-21
No files matched your search
+29
-14
@@ -1,8 +1,9 @@
|
||||
use anyhow::anyhow;
|
||||
use chrono::NaiveDateTime;
|
||||
use sqlx::{MySql, MySqlPool, Transaction};
|
||||
|
||||
use errors::AnyhowResult;
|
||||
use sqlx::mysql::MySqlArguments;
|
||||
use sqlx::query::Query;
|
||||
use sqlx::{MySql, MySqlPool, Transaction};
|
||||
|
||||
// TODO: Make a trait with default impls to handle common query concerns.
|
||||
|
||||
@@ -20,9 +21,32 @@ pub struct InsertStripeWebhookEventLog {
|
||||
|
||||
impl InsertStripeWebhookEventLog {
|
||||
|
||||
pub async fn insert(&self, transaction: &mut Transaction<'_, MySql>) -> AnyhowResult<()> {
|
||||
pub async fn insert(&self, mysql_pool: &MySqlPool) -> AnyhowResult<()> {
|
||||
let query_result = self.query()
|
||||
.execute(mysql_pool).await;
|
||||
|
||||
let query = sqlx::query!(
|
||||
let _record_id = match query_result {
|
||||
Ok(res) => res.last_insert_id(),
|
||||
Err(err) => return Err(anyhow!("Error creating stripe webhook event log: {:?}", err)),
|
||||
};
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn insert_transactional(&self, transaction: &mut Transaction<'_, MySql>) -> AnyhowResult<()> {
|
||||
let query_result = self.query()
|
||||
.execute(&mut **transaction).await;
|
||||
|
||||
let _record_id = match query_result {
|
||||
Ok(res) => res.last_insert_id(),
|
||||
Err(err) => return Err(anyhow!("Error creating stripe webhook event log: {:?}", err)),
|
||||
};
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn query(&self) -> Query<MySql, MySqlArguments> {
|
||||
sqlx::query!(
|
||||
r#"
|
||||
INSERT INTO stripe_webhook_event_logs
|
||||
SET
|
||||
@@ -45,15 +69,6 @@ SET
|
||||
&self.maybe_user_token,
|
||||
self.action_was_taken,
|
||||
self.should_ignore_retry,
|
||||
);
|
||||
|
||||
let query_result = query.execute(transaction).await;
|
||||
|
||||
let _record_id = match query_result {
|
||||
Ok(res) => res.last_insert_id(),
|
||||
Err(err) => return Err(anyhow!("Error creating stripe webhook event log: {:?}", err)),
|
||||
};
|
||||
|
||||
Ok(())
|
||||
)
|
||||
}
|
||||
}
|
||||
+6
-6
@@ -145,7 +145,7 @@ pub async fn stripe_artcraft_webhook_handler(
|
||||
stripe_event_type.clone(),
|
||||
stripe_is_production,
|
||||
&mut transaction
|
||||
).await?;
|
||||
).await;
|
||||
|
||||
match result {
|
||||
Ok(()) => {
|
||||
@@ -172,18 +172,18 @@ async fn do_with_transaction(
|
||||
stripe_event_created_at: NaiveDateTime,
|
||||
stripe_event_type: String,
|
||||
stripe_is_production: bool,
|
||||
mut transaction:
|
||||
&mut Transaction<MySql>
|
||||
transaction: &mut Transaction<'_, MySql>
|
||||
) -> Result<(), StripeArtcraftWebhookError> {
|
||||
|
||||
let webhook_summary = handle_webhook_payload(
|
||||
&mut transaction,
|
||||
transaction,
|
||||
&stripe_config.client,
|
||||
**server_environment,
|
||||
server_environment,
|
||||
webhook_payload,
|
||||
&stripe_event_type,
|
||||
).await?;
|
||||
|
||||
// NB: These records are uniquely keyed by ID, so this only happens once.
|
||||
let query = InsertStripeWebhookEventLog {
|
||||
stripe_event_id,
|
||||
stripe_event_type,
|
||||
@@ -196,7 +196,7 @@ async fn do_with_transaction(
|
||||
should_ignore_retry: webhook_summary.should_ignore_retry,
|
||||
};
|
||||
|
||||
query.insert(transaction)
|
||||
query.insert_transactional(transaction)
|
||||
.await
|
||||
.map_err(|err| {
|
||||
let reason = format!("Could not insert Stripe webhook event log: {:?}", err);
|
||||
|
||||
+2
-1
@@ -87,6 +87,7 @@ pub async fn handle_webhook_payload(
|
||||
|
||||
// =============== CUSTOMER SUBSCRIPTIONS ===============
|
||||
|
||||
/* TODO - temporary disable
|
||||
EventObject::CustomerSubscriptionCreated(subscription) => {
|
||||
info!("Event: {}, data: {:?}", webhook_payload.type_, subscription);
|
||||
// DO NOT USE TO PROVISION SERVICE.
|
||||
@@ -131,7 +132,7 @@ pub async fn handle_webhook_payload(
|
||||
server_environment,
|
||||
transaction,
|
||||
).await?;
|
||||
}
|
||||
}*/
|
||||
|
||||
// =============== INVOICES ===============
|
||||
|
||||
|
||||
Reference in new issue
Block a user