fix: rate limiting

fix: wait longer for invoice
This commit is contained in:
trisua 2025-05-07 21:54:21 -04:00
parent 797231946a
commit aca1a8236c
4 changed files with 21 additions and 5 deletions

View file

@ -157,6 +157,14 @@ macro_rules! check_user_blocked_or_private {
.await
.is_ok(),
);
context.insert(
"is_following",
&$data
.0
.get_userfollow_by_initiator_receiver(ua.id, $other_user.id)
.await
.is_ok(),
);
return Ok(Html(
$data.1.render("profile/private.html", &context).unwrap(),

View file

@ -59,8 +59,8 @@ async fn main() {
// governor
let governor_config = Arc::new(
GovernorConfigBuilder::default()
.per_millisecond(75)
.burst_size(32)
.per_millisecond(64)
.burst_size(128)
.finish()
.unwrap(),
);

View file

@ -1112,7 +1112,7 @@ show_kick=false, secondary=false) -%}
<div
class="flex justify-center flex-col"
style="{% if show_menu or show_kick %}width: 60%{% endif %}"
style="{% if show_menu or show_kick %}width: 60%{% else %}max-width: 200px{% endif %}"
>
{{ self::full_username(user=user) }}
<div class="user_status">{{ self::user_status(other_user=user) }}</div>

View file

@ -70,8 +70,8 @@ pub async fn stripe_webhook(
let customer_id = invoice.customer.unwrap().id();
// allow 10s for everything to finalize
tokio::time::sleep(Duration::from_secs(10)).await;
// allow 30s for everything to finalize
tokio::time::sleep(Duration::from_secs(30)).await;
// pull user and update role
let user = match data.get_user_by_stripe_id(customer_id.as_str()).await {
@ -79,6 +79,14 @@ pub async fn stripe_webhook(
Err(e) => return Json(e.into()),
};
if user.permissions.check(FinePermission::SUPPORTER) {
return Json(ApiReturn {
ok: true,
message: "Already applied".to_string(),
payload: (),
});
}
tracing::info!("invoice {} (stripe: {})", user.id, customer_id);
let new_user_permissions = user.permissions | FinePermission::SUPPORTER;