add: custom emojis
fix: don't show reposts of posts from blocked users fix: don't show questions when they're from users you've blocked
This commit is contained in:
parent
9f187039e6
commit
275dd0a1eb
25 changed files with 697 additions and 61 deletions
|
@ -1,7 +1,12 @@
|
|||
use std::time::Duration;
|
||||
|
||||
use axum::{http::HeaderMap, response::IntoResponse, Extension, Json};
|
||||
use tetratto_core::model::{auth::Notification, permissions::FinePermission, ApiReturn, Error};
|
||||
use tetratto_core::model::{
|
||||
auth::{User, Notification},
|
||||
moderation::AuditLogEntry,
|
||||
permissions::FinePermission,
|
||||
ApiReturn, Error,
|
||||
};
|
||||
use stripe::{EventObject, EventType};
|
||||
use crate::State;
|
||||
|
||||
|
@ -70,14 +75,50 @@ pub async fn stripe_webhook(
|
|||
|
||||
let customer_id = invoice.customer.unwrap().id();
|
||||
|
||||
// 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 {
|
||||
Ok(ua) => ua,
|
||||
Err(e) => return Json(e.into()),
|
||||
};
|
||||
let mut retries: usize = 0;
|
||||
let mut user: Option<User> = None;
|
||||
|
||||
loop {
|
||||
if retries >= 5 {
|
||||
// we've already tried 5 times (10 seconds of waiting)... it's not
|
||||
// going to happen
|
||||
//
|
||||
// we're going to report this error to the audit log so someone can
|
||||
// check manually later
|
||||
if let Err(e) = data
|
||||
.create_audit_log_entry(AuditLogEntry::new(
|
||||
0,
|
||||
format!("invoice tier update failed: stripe {customer_id}"),
|
||||
))
|
||||
.await
|
||||
{
|
||||
return Json(e.into());
|
||||
}
|
||||
|
||||
return Json(Error::GeneralNotFound("user".to_string()).into());
|
||||
}
|
||||
|
||||
match data.get_user_by_stripe_id(customer_id.as_str()).await {
|
||||
Ok(ua) => {
|
||||
if !user.is_none() {
|
||||
break;
|
||||
}
|
||||
|
||||
user = Some(ua);
|
||||
break;
|
||||
}
|
||||
Err(_) => {
|
||||
tracing::info!("checkout session not stored in db yet");
|
||||
retries += 1;
|
||||
tokio::time::sleep(Duration::from_secs(2)).await;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let user = user.unwrap();
|
||||
tracing::info!("found subscription user in {retries} tries");
|
||||
|
||||
if user.permissions.check(FinePermission::SUPPORTER) {
|
||||
return Json(ApiReturn {
|
||||
|
|
|
@ -216,7 +216,7 @@ pub async fn logout_request(
|
|||
Json(ApiReturn {
|
||||
ok: true,
|
||||
message: "Goodbye!".to_string(),
|
||||
payload: (),
|
||||
payload: Some(user.username.clone()),
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue