remove invoice auto collection on nwc_url update
This commit is contained in:
@@ -110,7 +110,7 @@ pub async fn update_tenant(
|
|||||||
api.require_admin_or_tenant(&auth, &pubkey)?;
|
api.require_admin_or_tenant(&auth, &pubkey)?;
|
||||||
let mut tenant = api.get_tenant_or_404(&pubkey).await?;
|
let mut tenant = api.get_tenant_or_404(&pubkey).await?;
|
||||||
|
|
||||||
let nwc_previously_empty = tenant.nwc_url.is_empty();
|
// Encrypt tenant's nwc_url at rest
|
||||||
if let Some(nwc_url) = payload.nwc_url {
|
if let Some(nwc_url) = payload.nwc_url {
|
||||||
if nwc_url.is_empty() {
|
if nwc_url.is_empty() {
|
||||||
tenant.nwc_url = String::new();
|
tenant.nwc_url = String::new();
|
||||||
@@ -120,21 +120,6 @@ pub async fn update_tenant(
|
|||||||
}
|
}
|
||||||
|
|
||||||
api.command.update_tenant(&tenant).await.map_err(internal)?;
|
api.command.update_tenant(&tenant).await.map_err(internal)?;
|
||||||
|
|
||||||
// When NWC is first connected, attempt to pay any outstanding open invoices.
|
|
||||||
if nwc_previously_empty && !tenant.nwc_url.is_empty() {
|
|
||||||
let billing = api.billing.clone();
|
|
||||||
let tenant_clone = tenant.clone();
|
|
||||||
tokio::spawn(async move {
|
|
||||||
if let Err(e) = billing.pay_outstanding_nwc_invoices(&tenant_clone).await {
|
|
||||||
tracing::error!(
|
|
||||||
error = %e,
|
|
||||||
pubkey = %tenant_clone.pubkey,
|
|
||||||
"pay_outstanding_nwc_invoices failed after NWC setup"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
ok(TenantResponse::from(tenant))
|
ok(TenantResponse::from(tenant))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user