1
0

Payments/subscriptions support (#943)

* [wip] Payments/subscriptions support

* finish

* working payment flow

* finish subscriptions, lint, clippy, etc

* docker compose
This commit is contained in:
Geometrically
2024-08-14 17:14:52 -07:00
committed by GitHub
parent 60edbcd5f0
commit 1d0d8d7fbe
71 changed files with 4009 additions and 1101 deletions

View File

@@ -77,9 +77,9 @@ pub async fn organization_projects_get(
possible_organization_id.map(|x| x as i64),
info
)
.fetch_many(&**pool)
.try_filter_map(|e| async { Ok(e.right().map(|m| crate::database::models::ProjectId(m.id))) })
.try_collect::<Vec<crate::database::models::ProjectId>>()
.fetch(&**pool)
.map_ok(|m| database::models::ProjectId(m.id))
.try_collect::<Vec<database::models::ProjectId>>()
.await?;
let projects_data =
@@ -574,8 +574,8 @@ pub async fn organization_delete(
",
organization.id as database::models::ids::OrganizationId
)
.fetch_many(&mut *transaction)
.try_filter_map(|e| async { Ok(e.right().map(|c| crate::database::models::TeamId(c.id))) })
.fetch(&mut *transaction)
.map_ok(|c| database::models::TeamId(c.id))
.try_collect::<Vec<_>>()
.await?;

View File

@@ -12,7 +12,7 @@ use actix_web::{delete, get, post, web, HttpRequest, HttpResponse};
use chrono::Utc;
use hex::ToHex;
use hmac::{Hmac, Mac, NewMac};
use hyper::Method;
use reqwest::Method;
use rust_decimal::Decimal;
use serde::Deserialize;
use serde_json::json;

View File

@@ -98,8 +98,8 @@ pub async fn random_projects_get(
.map(|x| x.to_string())
.collect::<Vec<String>>(),
)
.fetch_many(&**pool)
.try_filter_map(|e| async { Ok(e.right().map(|m| db_ids::ProjectId(m.id))) })
.fetch(&**pool)
.map_ok(|m| db_ids::ProjectId(m.id))
.try_collect::<Vec<_>>()
.await?;
@@ -430,8 +430,8 @@ pub async fn project_edit(
",
project_item.inner.team_id as db_ids::TeamId
)
.fetch_many(&mut *transaction)
.try_filter_map(|e| async { Ok(e.right().map(|c| db_models::UserId(c.id))) })
.fetch(&mut *transaction)
.map_ok(|c| db_models::UserId(c.id))
.try_collect::<Vec<_>>()
.await?;

View File

@@ -260,11 +260,8 @@ pub async fn reports(
",
count.count as i64
)
.fetch_many(&**pool)
.try_filter_map(|e| async {
Ok(e.right()
.map(|m| crate::database::models::ids::ReportId(m.id)))
})
.fetch(&**pool)
.map_ok(|m| crate::database::models::ids::ReportId(m.id))
.try_collect::<Vec<crate::database::models::ids::ReportId>>()
.await?
} else {
@@ -278,11 +275,8 @@ pub async fn reports(
user.id.0 as i64,
count.count as i64
)
.fetch_many(&**pool)
.try_filter_map(|e| async {
Ok(e.right()
.map(|m| crate::database::models::ids::ReportId(m.id)))
})
.fetch(&**pool)
.map_ok(|m| crate::database::models::ids::ReportId(m.id))
.try_collect::<Vec<crate::database::models::ids::ReportId>>()
.await?
};

View File

@@ -129,22 +129,19 @@ pub async fn filter_authorized_threads(
&*project_thread_ids,
user_id as database::models::ids::UserId,
)
.fetch_many(&***pool)
.try_for_each(|e| {
if let Some(row) = e.right() {
check_threads.retain(|x| {
let bool = x.project_id.map(|x| x.0) == Some(row.id);
.fetch(&***pool)
.map_ok(|row| {
check_threads.retain(|x| {
let bool = x.project_id.map(|x| x.0) == Some(row.id);
if bool {
return_threads.push(x.clone());
}
if bool {
return_threads.push(x.clone());
}
!bool
});
}
futures::future::ready(Ok(()))
!bool
});
})
.try_collect::<Vec<()>>()
.await?;
}
@@ -165,22 +162,19 @@ pub async fn filter_authorized_threads(
&*project_thread_ids,
user_id as database::models::ids::UserId,
)
.fetch_many(&***pool)
.try_for_each(|e| {
if let Some(row) = e.right() {
check_threads.retain(|x| {
let bool = x.project_id.map(|x| x.0) == Some(row.id);
.fetch(&***pool)
.map_ok(|row| {
check_threads.retain(|x| {
let bool = x.project_id.map(|x| x.0) == Some(row.id);
if bool {
return_threads.push(x.clone());
}
if bool {
return_threads.push(x.clone());
}
!bool
});
}
futures::future::ready(Ok(()))
!bool
});
})
.try_collect::<Vec<()>>()
.await?;
}
@@ -199,22 +193,19 @@ pub async fn filter_authorized_threads(
&*report_thread_ids,
user_id as database::models::ids::UserId,
)
.fetch_many(&***pool)
.try_for_each(|e| {
if let Some(row) = e.right() {
check_threads.retain(|x| {
let bool = x.report_id.map(|x| x.0) == Some(row.id);
.fetch(&***pool)
.map_ok(|row| {
check_threads.retain(|x| {
let bool = x.report_id.map(|x| x.0) == Some(row.id);
if bool {
return_threads.push(x.clone());
}
if bool {
return_threads.push(x.clone());
}
!bool
});
}
futures::future::ready(Ok(()))
!bool
});
})
.try_collect::<Vec<()>>()
.await?;
}
}

View File

@@ -610,11 +610,8 @@ pub async fn user_follows(
",
id as crate::database::models::ids::UserId,
)
.fetch_many(&**pool)
.try_filter_map(|e| async {
Ok(e.right()
.map(|m| crate::database::models::ProjectId(m.mod_id)))
})
.fetch(&**pool)
.map_ok(|m| crate::database::models::ProjectId(m.mod_id))
.try_collect::<Vec<crate::database::models::ProjectId>>()
.await?;

View File

@@ -394,8 +394,8 @@ async fn version_create_inner(
",
builder.project_id as crate::database::models::ids::ProjectId
)
.fetch_many(&mut **transaction)
.try_filter_map(|e| async { Ok(e.right().map(|m| models::ids::UserId(m.follower_id))) })
.fetch(&mut **transaction)
.map_ok(|m| models::ids::UserId(m.follower_id))
.try_collect::<Vec<models::ids::UserId>>()
.await?;