This commit is contained in:
Andras Schmelczer 2026-03-15 17:38:26 +00:00
parent 80c093b7ba
commit f72c43a9fa
101 changed files with 2168 additions and 1177 deletions

View file

@ -55,7 +55,10 @@ pub async fn post_stripe_webhook(
) -> Response {
let webhook_secret = &state.stripe_webhook_secret;
let sig_header = match headers.get("stripe-signature").and_then(|h| h.to_str().ok()) {
let sig_header = match headers
.get("stripe-signature")
.and_then(|h| h.to_str().ok())
{
Some(s) => s,
None => {
warn!("Missing Stripe-Signature header");
@ -90,8 +93,13 @@ pub async fn post_stripe_webhook(
// Update user subscription to "licensed" via PocketBase superuser auth
let pb_url = state.pocketbase_url.trim_end_matches('/');
let token = match auth_superuser(&state.http_client, pb_url, &state.pocketbase_admin_email, &state.pocketbase_admin_password)
.await
let token = match auth_superuser(
&state.http_client,
pb_url,
&state.pocketbase_admin_email,
&state.pocketbase_admin_password,
)
.await
{
Ok(t) => t,
Err(err) => {
@ -112,12 +120,18 @@ pub async fn post_stripe_webhook(
match res {
Ok(resp) if resp.status().is_success() => {
state.token_cache.invalidate_by_user_id(user_id);
info!(user_id, "User subscription updated to licensed via Stripe webhook");
info!(
user_id,
"User subscription updated to licensed via Stripe webhook"
);
}
Ok(resp) => {
let status = resp.status();
let text = resp.text().await.unwrap_or_default();
warn!(user_id, "Failed to update user subscription ({status}): {text}");
warn!(
user_id,
"Failed to update user subscription ({status}): {text}"
);
}
Err(err) => {
warn!(user_id, "PocketBase request error in webhook: {err}");