소스 검색

fix(strike): delete current strike webhooks

thesimplekid 7 달 전
부모
커밋
36f80efc54
2개의 변경된 파일10개의 추가작업 그리고 1개의 파일을 삭제
  1. 2 1
      crates/cdk-strike/Cargo.toml
  2. 8 0
      crates/cdk-strike/src/lib.rs

+ 2 - 1
crates/cdk-strike/Cargo.toml

@@ -20,4 +20,5 @@ tokio.workspace = true
 tracing.workspace = true
 thiserror.workspace = true
 uuid.workspace = true
-strike-rs = "0.1.0"
+# strike-rs = "0.1.0"
+strike-rs = { git = "https://github.com/thesimplekid/strike-rs" }

+ 8 - 0
crates/cdk-strike/src/lib.rs

@@ -221,6 +221,14 @@ impl Strike {
         webhook_endpoint: &str,
         sender: tokio::sync::mpsc::Sender<String>,
     ) -> anyhow::Result<Router> {
+        let subs = self.strike_api.get_current_subscriptions().await?;
+
+        tracing::debug!("Got {} current subscriptions", subs.len());
+
+        for sub in subs {
+            self.strike_api.delete_subscription(sub.id).await?;
+        }
+
         self.strike_api
             .create_invoice_webhook_router(webhook_endpoint, sender)
             .await