You've already forked AstralRinth
forked from didirus/AstralRinth
Commonize and distinguish a lot of struct names in labrinth::database::models (#3691)
This commit is contained in:
@@ -204,7 +204,7 @@ pub async fn delphi_result_ingest(
|
||||
|
||||
let webhook_url = dotenvy::var("DELPHI_SLACK_WEBHOOK")?;
|
||||
|
||||
let project = crate::database::models::Project::get_id(
|
||||
let project = crate::database::models::DBProject::get_id(
|
||||
body.project_id.into(),
|
||||
&**pool,
|
||||
&redis,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::auth::{get_user_from_headers, send_email};
|
||||
use crate::database::models::charge_item::ChargeItem;
|
||||
use crate::database::models::charge_item::DBCharge;
|
||||
use crate::database::models::{
|
||||
generate_charge_id, generate_user_subscription_id, product_item,
|
||||
user_subscription_item,
|
||||
@@ -59,7 +59,8 @@ pub async fn products(
|
||||
pool: web::Data<PgPool>,
|
||||
redis: web::Data<RedisPool>,
|
||||
) -> Result<HttpResponse, ApiError> {
|
||||
let products = product_item::QueryProduct::list(&**pool, &redis).await?;
|
||||
let products =
|
||||
product_item::QueryProductWithPrices::list(&**pool, &redis).await?;
|
||||
|
||||
let products = products
|
||||
.into_iter()
|
||||
@@ -107,7 +108,7 @@ pub async fn subscriptions(
|
||||
.1;
|
||||
|
||||
let subscriptions =
|
||||
user_subscription_item::UserSubscriptionItem::get_all_user(
|
||||
user_subscription_item::DBUserSubscription::get_all_user(
|
||||
if let Some(user_id) = query.user_id {
|
||||
if user.role.is_admin() {
|
||||
user_id.into()
|
||||
@@ -173,8 +174,8 @@ pub async fn refund_charge(
|
||||
));
|
||||
}
|
||||
|
||||
if let Some(charge) = ChargeItem::get(id.into(), &**pool).await? {
|
||||
let refunds = ChargeItem::get_children(id.into(), &**pool).await?;
|
||||
if let Some(charge) = DBCharge::get(id.into(), &**pool).await? {
|
||||
let refunds = DBCharge::get_children(id.into(), &**pool).await?;
|
||||
let refunds = -refunds
|
||||
.into_iter()
|
||||
.filter_map(|x| match x.status {
|
||||
@@ -261,7 +262,7 @@ pub async fn refund_charge(
|
||||
let mut transaction = pool.begin().await?;
|
||||
|
||||
let charge_id = generate_charge_id(&mut transaction).await?;
|
||||
ChargeItem {
|
||||
DBCharge {
|
||||
id: charge_id,
|
||||
user_id: charge.user_id,
|
||||
price_id: charge.price_id,
|
||||
@@ -284,7 +285,7 @@ pub async fn refund_charge(
|
||||
if body.0.unprovision.unwrap_or(false) {
|
||||
if let Some(subscription_id) = charge.subscription_id {
|
||||
let open_charge =
|
||||
ChargeItem::get_open_subscription(subscription_id, &**pool)
|
||||
DBCharge::get_open_subscription(subscription_id, &**pool)
|
||||
.await?;
|
||||
if let Some(mut open_charge) = open_charge {
|
||||
open_charge.status = ChargeStatus::Cancelled;
|
||||
@@ -332,7 +333,7 @@ pub async fn edit_subscription(
|
||||
let (id,) = info.into_inner();
|
||||
|
||||
if let Some(subscription) =
|
||||
user_subscription_item::UserSubscriptionItem::get(id.into(), &**pool)
|
||||
user_subscription_item::DBUserSubscription::get(id.into(), &**pool)
|
||||
.await?
|
||||
{
|
||||
if subscription.user_id != user.id.into() && !user.role.is_admin() {
|
||||
@@ -342,7 +343,7 @@ pub async fn edit_subscription(
|
||||
let mut transaction = pool.begin().await?;
|
||||
|
||||
let mut open_charge =
|
||||
crate::database::models::charge_item::ChargeItem::get_open_subscription(
|
||||
crate::database::models::charge_item::DBCharge::get_open_subscription(
|
||||
subscription.id,
|
||||
&mut *transaction,
|
||||
)
|
||||
@@ -353,7 +354,7 @@ pub async fn edit_subscription(
|
||||
)
|
||||
})?;
|
||||
|
||||
let current_price = product_item::ProductPriceItem::get(
|
||||
let current_price = product_item::DBProductPrice::get(
|
||||
subscription.price_id,
|
||||
&mut *transaction,
|
||||
)
|
||||
@@ -397,7 +398,7 @@ pub async fn edit_subscription(
|
||||
|
||||
let intent = if let Some(product_id) = &edit_subscription.product {
|
||||
let product_price =
|
||||
product_item::ProductPriceItem::get_all_product_prices(
|
||||
product_item::DBProductPrice::get_all_product_prices(
|
||||
(*product_id).into(),
|
||||
&mut *transaction,
|
||||
)
|
||||
@@ -622,7 +623,7 @@ pub async fn charges(
|
||||
.1;
|
||||
|
||||
let charges =
|
||||
crate::database::models::charge_item::ChargeItem::get_from_user(
|
||||
crate::database::models::charge_item::DBCharge::get_from_user(
|
||||
if let Some(user_id) = query.user_id {
|
||||
if user.role.is_admin() {
|
||||
user_id.into()
|
||||
@@ -829,7 +830,7 @@ pub async fn remove_payment_method(
|
||||
.await?;
|
||||
|
||||
let user_subscriptions =
|
||||
user_subscription_item::UserSubscriptionItem::get_all_user(
|
||||
user_subscription_item::DBUserSubscription::get_all_user(
|
||||
user.id.into(),
|
||||
&**pool,
|
||||
)
|
||||
@@ -935,12 +936,11 @@ pub async fn active_servers(
|
||||
));
|
||||
}
|
||||
|
||||
let servers =
|
||||
user_subscription_item::UserSubscriptionItem::get_all_servers(
|
||||
query.subscription_status,
|
||||
&**pool,
|
||||
)
|
||||
.await?;
|
||||
let servers = user_subscription_item::DBUserSubscription::get_all_servers(
|
||||
query.subscription_status,
|
||||
&**pool,
|
||||
)
|
||||
.await?;
|
||||
|
||||
#[derive(Serialize)]
|
||||
struct ActiveServer {
|
||||
@@ -1153,7 +1153,7 @@ pub async fn initiate_payment(
|
||||
match payment_request.charge {
|
||||
ChargeRequestType::Existing { id } => {
|
||||
let charge =
|
||||
crate::database::models::charge_item::ChargeItem::get(
|
||||
crate::database::models::charge_item::DBCharge::get(
|
||||
id.into(),
|
||||
&**pool,
|
||||
)
|
||||
@@ -1178,7 +1178,7 @@ pub async fn initiate_payment(
|
||||
interval,
|
||||
} => {
|
||||
let product =
|
||||
product_item::ProductItem::get(product_id.into(), &**pool)
|
||||
product_item::DBProduct::get(product_id.into(), &**pool)
|
||||
.await?
|
||||
.ok_or_else(|| {
|
||||
ApiError::InvalidInput(
|
||||
@@ -1188,7 +1188,7 @@ pub async fn initiate_payment(
|
||||
})?;
|
||||
|
||||
let mut product_prices =
|
||||
product_item::ProductPriceItem::get_all_product_prices(
|
||||
product_item::DBProductPrice::get_all_product_prices(
|
||||
product.id, &**pool,
|
||||
)
|
||||
.await?;
|
||||
@@ -1229,14 +1229,14 @@ pub async fn initiate_payment(
|
||||
if let Price::Recurring { .. } = price_item.prices {
|
||||
if product.unitary {
|
||||
let user_subscriptions =
|
||||
user_subscription_item::UserSubscriptionItem::get_all_user(
|
||||
user_subscription_item::DBUserSubscription::get_all_user(
|
||||
user.id.into(),
|
||||
&**pool,
|
||||
)
|
||||
.await?;
|
||||
|
||||
let user_products =
|
||||
product_item::ProductPriceItem::get_many(
|
||||
product_item::DBProductPrice::get_many(
|
||||
&user_subscriptions
|
||||
.iter()
|
||||
.filter(|x| {
|
||||
@@ -1413,12 +1413,12 @@ pub async fn stripe_webhook(
|
||||
&dotenvy::var("STRIPE_WEBHOOK_SECRET")?,
|
||||
) {
|
||||
struct PaymentIntentMetadata {
|
||||
pub user_item: crate::database::models::user_item::User,
|
||||
pub product_price_item: product_item::ProductPriceItem,
|
||||
pub product_item: product_item::ProductItem,
|
||||
pub charge_item: crate::database::models::charge_item::ChargeItem,
|
||||
pub user_item: crate::database::models::user_item::DBUser,
|
||||
pub product_price_item: product_item::DBProductPrice,
|
||||
pub product_item: product_item::DBProduct,
|
||||
pub charge_item: crate::database::models::charge_item::DBCharge,
|
||||
pub user_subscription_item:
|
||||
Option<user_subscription_item::UserSubscriptionItem>,
|
||||
Option<user_subscription_item::DBUserSubscription>,
|
||||
pub payment_metadata: Option<PaymentRequestMetadata>,
|
||||
#[allow(dead_code)]
|
||||
pub charge_type: ChargeType,
|
||||
@@ -1447,7 +1447,7 @@ pub async fn stripe_webhook(
|
||||
};
|
||||
|
||||
let user = if let Some(user) =
|
||||
crate::database::models::user_item::User::get_id(
|
||||
crate::database::models::user_item::DBUser::get_id(
|
||||
user_id, pool, redis,
|
||||
)
|
||||
.await?
|
||||
@@ -1483,17 +1483,14 @@ pub async fn stripe_webhook(
|
||||
let (charge, price, product, subscription) = if let Some(
|
||||
mut charge,
|
||||
) =
|
||||
crate::database::models::charge_item::ChargeItem::get(
|
||||
crate::database::models::charge_item::DBCharge::get(
|
||||
charge_id, pool,
|
||||
)
|
||||
.await?
|
||||
{
|
||||
let price = if let Some(price) =
|
||||
product_item::ProductPriceItem::get(
|
||||
charge.price_id,
|
||||
pool,
|
||||
)
|
||||
.await?
|
||||
product_item::DBProductPrice::get(charge.price_id, pool)
|
||||
.await?
|
||||
{
|
||||
price
|
||||
} else {
|
||||
@@ -1501,7 +1498,7 @@ pub async fn stripe_webhook(
|
||||
};
|
||||
|
||||
let product = if let Some(product) =
|
||||
product_item::ProductItem::get(price.product_id, pool)
|
||||
product_item::DBProduct::get(price.product_id, pool)
|
||||
.await?
|
||||
{
|
||||
product
|
||||
@@ -1517,7 +1514,7 @@ pub async fn stripe_webhook(
|
||||
|
||||
if let Some(subscription_id) = charge.subscription_id {
|
||||
let mut subscription = if let Some(subscription) =
|
||||
user_subscription_item::UserSubscriptionItem::get(
|
||||
user_subscription_item::DBUserSubscription::get(
|
||||
subscription_id,
|
||||
pool,
|
||||
)
|
||||
@@ -1567,7 +1564,7 @@ pub async fn stripe_webhook(
|
||||
};
|
||||
|
||||
let price = if let Some(price) =
|
||||
product_item::ProductPriceItem::get(price_id, pool)
|
||||
product_item::DBProductPrice::get(price_id, pool)
|
||||
.await?
|
||||
{
|
||||
price
|
||||
@@ -1576,7 +1573,7 @@ pub async fn stripe_webhook(
|
||||
};
|
||||
|
||||
let product = if let Some(product) =
|
||||
product_item::ProductItem::get(price.product_id, pool)
|
||||
product_item::DBProduct::get(price.product_id, pool)
|
||||
.await?
|
||||
{
|
||||
product
|
||||
@@ -1608,14 +1605,14 @@ pub async fn stripe_webhook(
|
||||
break 'metadata;
|
||||
};
|
||||
|
||||
let subscription = if let Some(mut subscription) = user_subscription_item::UserSubscriptionItem::get(subscription_id, pool).await? {
|
||||
let subscription = if let Some(mut subscription) = user_subscription_item::DBUserSubscription::get(subscription_id, pool).await? {
|
||||
subscription.status = SubscriptionStatus::Unprovisioned;
|
||||
subscription.price_id = price_id;
|
||||
subscription.interval = interval;
|
||||
|
||||
subscription
|
||||
} else {
|
||||
user_subscription_item::UserSubscriptionItem {
|
||||
user_subscription_item::DBUserSubscription {
|
||||
id: subscription_id,
|
||||
user_id,
|
||||
price_id,
|
||||
@@ -1637,7 +1634,7 @@ pub async fn stripe_webhook(
|
||||
}
|
||||
};
|
||||
|
||||
let charge = ChargeItem {
|
||||
let charge = DBCharge {
|
||||
id: charge_id,
|
||||
user_id,
|
||||
price_id,
|
||||
@@ -1870,7 +1867,7 @@ pub async fn stripe_webhook(
|
||||
if let Some(mut subscription) =
|
||||
metadata.user_subscription_item
|
||||
{
|
||||
let open_charge = ChargeItem::get_open_subscription(
|
||||
let open_charge = DBCharge::get_open_subscription(
|
||||
subscription.id,
|
||||
&mut *transaction,
|
||||
)
|
||||
@@ -1898,7 +1895,7 @@ pub async fn stripe_webhook(
|
||||
{
|
||||
let charge_id =
|
||||
generate_charge_id(&mut transaction).await?;
|
||||
ChargeItem {
|
||||
DBCharge {
|
||||
id: charge_id,
|
||||
user_id: metadata.user_item.id,
|
||||
price_id: metadata.product_price_item.id,
|
||||
@@ -1936,7 +1933,7 @@ pub async fn stripe_webhook(
|
||||
}
|
||||
|
||||
transaction.commit().await?;
|
||||
crate::database::models::user_item::User::clear_caches(
|
||||
crate::database::models::user_item::DBUser::clear_caches(
|
||||
&[(metadata.user_item.id, None)],
|
||||
&redis,
|
||||
)
|
||||
@@ -2098,7 +2095,7 @@ async fn get_or_create_customer(
|
||||
.execute(pool)
|
||||
.await?;
|
||||
|
||||
crate::database::models::user_item::User::clear_caches(
|
||||
crate::database::models::user_item::DBUser::clear_caches(
|
||||
&[(user_id.into(), None)],
|
||||
redis,
|
||||
)
|
||||
@@ -2116,10 +2113,10 @@ pub async fn index_subscriptions(pool: PgPool, redis: RedisPool) {
|
||||
let mut clear_cache_users = Vec::new();
|
||||
|
||||
// If an active subscription has a canceled charge OR a failed charge more than two days ago, it should be cancelled
|
||||
let all_charges = ChargeItem::get_unprovision(&pool).await?;
|
||||
let all_charges = DBCharge::get_unprovision(&pool).await?;
|
||||
|
||||
let mut all_subscriptions =
|
||||
user_subscription_item::UserSubscriptionItem::get_many(
|
||||
user_subscription_item::DBUserSubscription::get_many(
|
||||
&all_charges
|
||||
.iter()
|
||||
.filter_map(|x| x.subscription_id)
|
||||
@@ -2129,7 +2126,7 @@ pub async fn index_subscriptions(pool: PgPool, redis: RedisPool) {
|
||||
&pool,
|
||||
)
|
||||
.await?;
|
||||
let subscription_prices = product_item::ProductPriceItem::get_many(
|
||||
let subscription_prices = product_item::DBProductPrice::get_many(
|
||||
&all_subscriptions
|
||||
.iter()
|
||||
.map(|x| x.price_id)
|
||||
@@ -2139,7 +2136,7 @@ pub async fn index_subscriptions(pool: PgPool, redis: RedisPool) {
|
||||
&pool,
|
||||
)
|
||||
.await?;
|
||||
let subscription_products = product_item::ProductItem::get_many(
|
||||
let subscription_products = product_item::DBProduct::get_many(
|
||||
&subscription_prices
|
||||
.iter()
|
||||
.map(|x| x.product_id)
|
||||
@@ -2149,7 +2146,7 @@ pub async fn index_subscriptions(pool: PgPool, redis: RedisPool) {
|
||||
&pool,
|
||||
)
|
||||
.await?;
|
||||
let users = crate::database::models::User::get_many_ids(
|
||||
let users = crate::database::models::DBUser::get_many_ids(
|
||||
&all_subscriptions
|
||||
.iter()
|
||||
.map(|x| x.user_id)
|
||||
@@ -2260,7 +2257,7 @@ pub async fn index_subscriptions(pool: PgPool, redis: RedisPool) {
|
||||
clear_cache_users.push(user.id);
|
||||
}
|
||||
|
||||
crate::database::models::User::clear_caches(
|
||||
crate::database::models::DBUser::clear_caches(
|
||||
&clear_cache_users
|
||||
.into_iter()
|
||||
.map(|x| (x, None))
|
||||
@@ -2289,12 +2286,12 @@ pub async fn index_billing(
|
||||
let res = async {
|
||||
// If a charge is open and due or has been attempted more than two days ago, it should be processed
|
||||
let charges_to_do =
|
||||
crate::database::models::charge_item::ChargeItem::get_chargeable(
|
||||
crate::database::models::charge_item::DBCharge::get_chargeable(
|
||||
&pool,
|
||||
)
|
||||
.await?;
|
||||
|
||||
let prices = product_item::ProductPriceItem::get_many(
|
||||
let prices = product_item::DBProductPrice::get_many(
|
||||
&charges_to_do
|
||||
.iter()
|
||||
.map(|x| x.price_id)
|
||||
@@ -2305,7 +2302,7 @@ pub async fn index_billing(
|
||||
)
|
||||
.await?;
|
||||
|
||||
let users = crate::database::models::User::get_many_ids(
|
||||
let users = crate::database::models::DBUser::get_many_ids(
|
||||
&charges_to_do
|
||||
.iter()
|
||||
.map(|x| x.user_id)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use crate::auth::email::send_email;
|
||||
use crate::auth::validate::get_user_record_from_bearer_token;
|
||||
use crate::auth::{AuthProvider, AuthenticationError, get_user_from_headers};
|
||||
use crate::database::models::flow_item::Flow;
|
||||
use crate::database::models::flow_item::DBFlow;
|
||||
use crate::database::redis::RedisPool;
|
||||
use crate::file_hosting::FileHost;
|
||||
use crate::models::pats::Scopes;
|
||||
@@ -76,7 +76,7 @@ impl TempUser {
|
||||
redis: &RedisPool,
|
||||
) -> Result<crate::database::models::DBUserId, AuthenticationError> {
|
||||
if let Some(email) = &self.email {
|
||||
if crate::database::models::User::get_email(email, client)
|
||||
if crate::database::models::DBUser::get_email(email, client)
|
||||
.await?
|
||||
.is_some()
|
||||
{
|
||||
@@ -101,7 +101,7 @@ impl TempUser {
|
||||
}
|
||||
);
|
||||
|
||||
let new_id = crate::database::models::User::get(
|
||||
let new_id = crate::database::models::DBUser::get(
|
||||
&test_username,
|
||||
client,
|
||||
redis,
|
||||
@@ -156,7 +156,7 @@ impl TempUser {
|
||||
};
|
||||
|
||||
if let Some(username) = username {
|
||||
crate::database::models::User {
|
||||
crate::database::models::DBUser {
|
||||
id: user_id,
|
||||
github_id: if provider == AuthProvider::GitHub {
|
||||
Some(
|
||||
@@ -1083,7 +1083,7 @@ pub async fn init(
|
||||
None
|
||||
};
|
||||
|
||||
let state = Flow::OAuth {
|
||||
let state = DBFlow::OAuth {
|
||||
user_id,
|
||||
url: info.url,
|
||||
provider: info.provider,
|
||||
@@ -1112,16 +1112,16 @@ pub async fn auth_callback(
|
||||
|
||||
let state = state_string.clone();
|
||||
let res: Result<HttpResponse, AuthenticationError> = async move {
|
||||
let flow = Flow::get(&state, &redis).await?;
|
||||
let flow = DBFlow::get(&state, &redis).await?;
|
||||
|
||||
// Extract cookie header from request
|
||||
if let Some(Flow::OAuth {
|
||||
if let Some(DBFlow::OAuth {
|
||||
user_id,
|
||||
provider,
|
||||
url,
|
||||
}) = flow
|
||||
{
|
||||
Flow::remove(&state, &redis).await?;
|
||||
DBFlow::remove(&state, &redis).await?;
|
||||
|
||||
let token = provider.get_token(query).await?;
|
||||
let oauth_user = provider.get_user(&token).await?;
|
||||
@@ -1138,7 +1138,7 @@ pub async fn auth_callback(
|
||||
.update_user_id(id, Some(&oauth_user.id), &mut transaction)
|
||||
.await?;
|
||||
|
||||
let user = crate::database::models::User::get_id(id, &**client, &redis).await?;
|
||||
let user = crate::database::models::DBUser::get_id(id, &**client, &redis).await?;
|
||||
|
||||
if provider == AuthProvider::PayPal {
|
||||
sqlx::query!(
|
||||
@@ -1165,19 +1165,19 @@ pub async fn auth_callback(
|
||||
}
|
||||
|
||||
transaction.commit().await?;
|
||||
crate::database::models::User::clear_caches(&[(id, None)], &redis).await?;
|
||||
crate::database::models::DBUser::clear_caches(&[(id, None)], &redis).await?;
|
||||
|
||||
Ok(HttpResponse::TemporaryRedirect()
|
||||
.append_header(("Location", &*url))
|
||||
.json(serde_json::json!({ "url": url })))
|
||||
} else {
|
||||
let user_id = if let Some(user_id) = user_id_opt {
|
||||
let user = crate::database::models::User::get_id(user_id, &**client, &redis)
|
||||
let user = crate::database::models::DBUser::get_id(user_id, &**client, &redis)
|
||||
.await?
|
||||
.ok_or_else(|| AuthenticationError::InvalidCredentials)?;
|
||||
|
||||
if user.totp_secret.is_some() {
|
||||
let flow = Flow::Login2FA { user_id: user.id }
|
||||
let flow = DBFlow::Login2FA { user_id: user.id }
|
||||
.insert(Duration::minutes(30), &redis)
|
||||
.await?;
|
||||
|
||||
@@ -1279,7 +1279,7 @@ pub async fn delete_auth_provider(
|
||||
}
|
||||
|
||||
transaction.commit().await?;
|
||||
crate::database::models::User::clear_caches(
|
||||
crate::database::models::DBUser::clear_caches(
|
||||
&[(user.id.into(), None)],
|
||||
&redis,
|
||||
)
|
||||
@@ -1346,7 +1346,7 @@ pub async fn create_account_with_password(
|
||||
return Err(ApiError::Turnstile);
|
||||
}
|
||||
|
||||
if crate::database::models::User::get(
|
||||
if crate::database::models::DBUser::get(
|
||||
&new_account.username,
|
||||
&**pool,
|
||||
&redis,
|
||||
@@ -1385,7 +1385,7 @@ pub async fn create_account_with_password(
|
||||
.hash_password(new_account.password.as_bytes(), &salt)?
|
||||
.to_string();
|
||||
|
||||
if crate::database::models::User::get_email(&new_account.email, &**pool)
|
||||
if crate::database::models::DBUser::get_email(&new_account.email, &**pool)
|
||||
.await?
|
||||
.is_some()
|
||||
{
|
||||
@@ -1394,7 +1394,7 @@ pub async fn create_account_with_password(
|
||||
));
|
||||
}
|
||||
|
||||
crate::database::models::User {
|
||||
crate::database::models::DBUser {
|
||||
id: user_id,
|
||||
github_id: None,
|
||||
discord_id: None,
|
||||
@@ -1426,7 +1426,7 @@ pub async fn create_account_with_password(
|
||||
let session = issue_session(req, user_id, &mut transaction, &redis).await?;
|
||||
let res = crate::models::sessions::Session::from(session, true, None);
|
||||
|
||||
let flow = Flow::ConfirmEmail {
|
||||
let flow = DBFlow::ConfirmEmail {
|
||||
user_id,
|
||||
confirm_email: new_account.email.clone(),
|
||||
}
|
||||
@@ -1467,17 +1467,19 @@ pub async fn login_password(
|
||||
}
|
||||
|
||||
let user = if let Some(user) =
|
||||
crate::database::models::User::get(&login.username, &**pool, &redis)
|
||||
crate::database::models::DBUser::get(&login.username, &**pool, &redis)
|
||||
.await?
|
||||
{
|
||||
user
|
||||
} else {
|
||||
let user =
|
||||
crate::database::models::User::get_email(&login.username, &**pool)
|
||||
.await?
|
||||
.ok_or_else(|| AuthenticationError::InvalidCredentials)?;
|
||||
let user = crate::database::models::DBUser::get_email(
|
||||
&login.username,
|
||||
&**pool,
|
||||
)
|
||||
.await?
|
||||
.ok_or_else(|| AuthenticationError::InvalidCredentials)?;
|
||||
|
||||
crate::database::models::User::get_id(user, &**pool, &redis)
|
||||
crate::database::models::DBUser::get_id(user, &**pool, &redis)
|
||||
.await?
|
||||
.ok_or_else(|| AuthenticationError::InvalidCredentials)?
|
||||
};
|
||||
@@ -1495,7 +1497,7 @@ pub async fn login_password(
|
||||
.map_err(|_| AuthenticationError::InvalidCredentials)?;
|
||||
|
||||
if user.totp_secret.is_some() {
|
||||
let flow = Flow::Login2FA { user_id: user.id }
|
||||
let flow = DBFlow::Login2FA { user_id: user.id }
|
||||
.insert(Duration::minutes(30), &redis)
|
||||
.await?;
|
||||
|
||||
@@ -1568,7 +1570,7 @@ async fn validate_2fa_code(
|
||||
Ok(true)
|
||||
} else if allow_backup {
|
||||
let backup_codes =
|
||||
crate::database::models::User::get_backup_codes(user_id, pool)
|
||||
crate::database::models::DBUser::get_backup_codes(user_id, pool)
|
||||
.await?;
|
||||
|
||||
if !backup_codes.contains(&input) {
|
||||
@@ -1587,7 +1589,7 @@ async fn validate_2fa_code(
|
||||
.execute(&mut **transaction)
|
||||
.await?;
|
||||
|
||||
crate::database::models::User::clear_caches(
|
||||
crate::database::models::DBUser::clear_caches(
|
||||
&[(user_id, None)],
|
||||
redis,
|
||||
)
|
||||
@@ -1607,13 +1609,13 @@ pub async fn login_2fa(
|
||||
redis: Data<RedisPool>,
|
||||
login: web::Json<Login2FA>,
|
||||
) -> Result<HttpResponse, ApiError> {
|
||||
let flow = Flow::get(&login.flow, &redis)
|
||||
let flow = DBFlow::get(&login.flow, &redis)
|
||||
.await?
|
||||
.ok_or_else(|| AuthenticationError::InvalidCredentials)?;
|
||||
|
||||
if let Flow::Login2FA { user_id } = flow {
|
||||
if let DBFlow::Login2FA { user_id } = flow {
|
||||
let user =
|
||||
crate::database::models::User::get_id(user_id, &**pool, &redis)
|
||||
crate::database::models::DBUser::get_id(user_id, &**pool, &redis)
|
||||
.await?
|
||||
.ok_or_else(|| AuthenticationError::InvalidCredentials)?;
|
||||
|
||||
@@ -1634,7 +1636,7 @@ pub async fn login_2fa(
|
||||
AuthenticationError::InvalidCredentials,
|
||||
));
|
||||
}
|
||||
Flow::remove(&login.flow, &redis).await?;
|
||||
DBFlow::remove(&login.flow, &redis).await?;
|
||||
|
||||
let session =
|
||||
issue_session(req, user_id, &mut transaction, &redis).await?;
|
||||
@@ -1670,7 +1672,7 @@ pub async fn begin_2fa_flow(
|
||||
let string = totp_rs::Secret::generate_secret();
|
||||
let encoded = string.to_encoded();
|
||||
|
||||
let flow = Flow::Initialize2FA {
|
||||
let flow = DBFlow::Initialize2FA {
|
||||
user_id: user.id.into(),
|
||||
secret: encoded.to_string(),
|
||||
}
|
||||
@@ -1696,11 +1698,11 @@ pub async fn finish_2fa_flow(
|
||||
login: web::Json<Login2FA>,
|
||||
session_queue: Data<AuthQueue>,
|
||||
) -> Result<HttpResponse, ApiError> {
|
||||
let flow = Flow::get(&login.flow, &redis)
|
||||
let flow = DBFlow::get(&login.flow, &redis)
|
||||
.await?
|
||||
.ok_or_else(|| AuthenticationError::InvalidCredentials)?;
|
||||
|
||||
if let Flow::Initialize2FA { user_id, secret } = flow {
|
||||
if let DBFlow::Initialize2FA { user_id, secret } = flow {
|
||||
let user = get_user_from_headers(
|
||||
&req,
|
||||
&**pool,
|
||||
@@ -1735,7 +1737,7 @@ pub async fn finish_2fa_flow(
|
||||
));
|
||||
}
|
||||
|
||||
Flow::remove(&login.flow, &redis).await?;
|
||||
DBFlow::remove(&login.flow, &redis).await?;
|
||||
|
||||
sqlx::query!(
|
||||
"
|
||||
@@ -1794,7 +1796,7 @@ pub async fn finish_2fa_flow(
|
||||
}
|
||||
|
||||
transaction.commit().await?;
|
||||
crate::database::models::User::clear_caches(
|
||||
crate::database::models::DBUser::clear_caches(
|
||||
&[(user.id.into(), None)],
|
||||
&redis,
|
||||
)
|
||||
@@ -1893,7 +1895,7 @@ pub async fn remove_2fa(
|
||||
}
|
||||
|
||||
transaction.commit().await?;
|
||||
crate::database::models::User::clear_caches(&[(user.id, None)], &redis)
|
||||
crate::database::models::DBUser::clear_caches(&[(user.id, None)], &redis)
|
||||
.await?;
|
||||
|
||||
Ok(HttpResponse::NoContent().finish())
|
||||
@@ -1916,15 +1918,17 @@ pub async fn reset_password_begin(
|
||||
return Err(ApiError::Turnstile);
|
||||
}
|
||||
|
||||
let user = if let Some(user_id) = crate::database::models::User::get_email(
|
||||
&reset_password.username,
|
||||
&**pool,
|
||||
)
|
||||
.await?
|
||||
let user = if let Some(user_id) =
|
||||
crate::database::models::DBUser::get_email(
|
||||
&reset_password.username,
|
||||
&**pool,
|
||||
)
|
||||
.await?
|
||||
{
|
||||
crate::database::models::User::get_id(user_id, &**pool, &redis).await?
|
||||
crate::database::models::DBUser::get_id(user_id, &**pool, &redis)
|
||||
.await?
|
||||
} else {
|
||||
crate::database::models::User::get(
|
||||
crate::database::models::DBUser::get(
|
||||
&reset_password.username,
|
||||
&**pool,
|
||||
&redis,
|
||||
@@ -1933,7 +1937,7 @@ pub async fn reset_password_begin(
|
||||
};
|
||||
|
||||
if let Some(user) = user {
|
||||
let flow = Flow::ForgotPassword { user_id: user.id }
|
||||
let flow = DBFlow::ForgotPassword { user_id: user.id }
|
||||
.insert(Duration::hours(24), &redis)
|
||||
.await?;
|
||||
|
||||
@@ -1975,13 +1979,14 @@ pub async fn change_password(
|
||||
session_queue: Data<AuthQueue>,
|
||||
) -> Result<HttpResponse, ApiError> {
|
||||
let user = if let Some(flow) = &change_password.flow {
|
||||
let flow = Flow::get(flow, &redis).await?;
|
||||
let flow = DBFlow::get(flow, &redis).await?;
|
||||
|
||||
if let Some(Flow::ForgotPassword { user_id }) = flow {
|
||||
let user =
|
||||
crate::database::models::User::get_id(user_id, &**pool, &redis)
|
||||
.await?
|
||||
.ok_or_else(|| AuthenticationError::InvalidCredentials)?;
|
||||
if let Some(DBFlow::ForgotPassword { user_id }) = flow {
|
||||
let user = crate::database::models::DBUser::get_id(
|
||||
user_id, &**pool, &redis,
|
||||
)
|
||||
.await?
|
||||
.ok_or_else(|| AuthenticationError::InvalidCredentials)?;
|
||||
|
||||
Some(user)
|
||||
} else {
|
||||
@@ -2085,7 +2090,7 @@ pub async fn change_password(
|
||||
.await?;
|
||||
|
||||
if let Some(flow) = &change_password.flow {
|
||||
Flow::remove(flow, &redis).await?;
|
||||
DBFlow::remove(flow, &redis).await?;
|
||||
}
|
||||
|
||||
if let Some(email) = user.email {
|
||||
@@ -2105,7 +2110,7 @@ pub async fn change_password(
|
||||
}
|
||||
|
||||
transaction.commit().await?;
|
||||
crate::database::models::User::clear_caches(&[(user.id, None)], &redis)
|
||||
crate::database::models::DBUser::clear_caches(&[(user.id, None)], &redis)
|
||||
.await?;
|
||||
|
||||
Ok(HttpResponse::Ok().finish())
|
||||
@@ -2183,7 +2188,7 @@ pub async fn set_email(
|
||||
.await?;
|
||||
}
|
||||
|
||||
let flow = Flow::ConfirmEmail {
|
||||
let flow = DBFlow::ConfirmEmail {
|
||||
user_id: user.id.into(),
|
||||
confirm_email: email.email.clone(),
|
||||
}
|
||||
@@ -2197,7 +2202,7 @@ pub async fn set_email(
|
||||
)?;
|
||||
|
||||
transaction.commit().await?;
|
||||
crate::database::models::User::clear_caches(
|
||||
crate::database::models::DBUser::clear_caches(
|
||||
&[(user.id.into(), None)],
|
||||
&redis,
|
||||
)
|
||||
@@ -2230,7 +2235,7 @@ pub async fn resend_verify_email(
|
||||
));
|
||||
}
|
||||
|
||||
let flow = Flow::ConfirmEmail {
|
||||
let flow = DBFlow::ConfirmEmail {
|
||||
user_id: user.id.into(),
|
||||
confirm_email: email.clone(),
|
||||
}
|
||||
@@ -2262,15 +2267,15 @@ pub async fn verify_email(
|
||||
redis: Data<RedisPool>,
|
||||
email: web::Json<VerifyEmail>,
|
||||
) -> Result<HttpResponse, ApiError> {
|
||||
let flow = Flow::get(&email.flow, &redis).await?;
|
||||
let flow = DBFlow::get(&email.flow, &redis).await?;
|
||||
|
||||
if let Some(Flow::ConfirmEmail {
|
||||
if let Some(DBFlow::ConfirmEmail {
|
||||
user_id,
|
||||
confirm_email,
|
||||
}) = flow
|
||||
{
|
||||
let user =
|
||||
crate::database::models::User::get_id(user_id, &**pool, &redis)
|
||||
crate::database::models::DBUser::get_id(user_id, &**pool, &redis)
|
||||
.await?
|
||||
.ok_or_else(|| AuthenticationError::InvalidCredentials)?;
|
||||
|
||||
@@ -2294,10 +2299,13 @@ pub async fn verify_email(
|
||||
.execute(&mut *transaction)
|
||||
.await?;
|
||||
|
||||
Flow::remove(&email.flow, &redis).await?;
|
||||
DBFlow::remove(&email.flow, &redis).await?;
|
||||
transaction.commit().await?;
|
||||
crate::database::models::User::clear_caches(&[(user.id, None)], &redis)
|
||||
.await?;
|
||||
crate::database::models::DBUser::clear_caches(
|
||||
&[(user.id, None)],
|
||||
&redis,
|
||||
)
|
||||
.await?;
|
||||
|
||||
Ok(HttpResponse::NoContent().finish())
|
||||
} else {
|
||||
|
||||
@@ -30,9 +30,9 @@ pub async fn export(
|
||||
let user_id = user.id.into();
|
||||
|
||||
let collection_ids =
|
||||
crate::database::models::User::get_collections(user_id, &**pool)
|
||||
crate::database::models::DBUser::get_collections(user_id, &**pool)
|
||||
.await?;
|
||||
let collections = crate::database::models::Collection::get_many(
|
||||
let collections = crate::database::models::DBCollection::get_many(
|
||||
&collection_ids,
|
||||
&**pool,
|
||||
&redis,
|
||||
@@ -42,24 +42,25 @@ pub async fn export(
|
||||
.map(crate::models::collections::Collection::from)
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let follows = crate::database::models::User::get_follows(user_id, &**pool)
|
||||
.await?
|
||||
.into_iter()
|
||||
.map(crate::models::ids::ProjectId::from)
|
||||
.collect::<Vec<_>>();
|
||||
let follows =
|
||||
crate::database::models::DBUser::get_follows(user_id, &**pool)
|
||||
.await?
|
||||
.into_iter()
|
||||
.map(crate::models::ids::ProjectId::from)
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let projects =
|
||||
crate::database::models::User::get_projects(user_id, &**pool, &redis)
|
||||
crate::database::models::DBUser::get_projects(user_id, &**pool, &redis)
|
||||
.await?
|
||||
.into_iter()
|
||||
.map(crate::models::ids::ProjectId::from)
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let org_ids =
|
||||
crate::database::models::User::get_organizations(user_id, &**pool)
|
||||
crate::database::models::DBUser::get_organizations(user_id, &**pool)
|
||||
.await?;
|
||||
let orgs =
|
||||
crate::database::models::organization_item::Organization::get_many_ids(
|
||||
crate::database::models::organization_item::DBOrganization::get_many_ids(
|
||||
&org_ids, &**pool, &redis,
|
||||
)
|
||||
.await?
|
||||
@@ -68,7 +69,7 @@ pub async fn export(
|
||||
.map(|x| crate::models::organizations::Organization::from(x, vec![]))
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let notifs = crate::database::models::notification_item::Notification::get_many_user(
|
||||
let notifs = crate::database::models::notification_item::DBNotification::get_many_user(
|
||||
user_id, &**pool, &redis,
|
||||
)
|
||||
.await?
|
||||
@@ -77,7 +78,7 @@ pub async fn export(
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let oauth_clients =
|
||||
crate::database::models::oauth_client_item::OAuthClient::get_all_user_clients(
|
||||
crate::database::models::oauth_client_item::DBOAuthClient::get_all_user_clients(
|
||||
user_id, &**pool,
|
||||
)
|
||||
.await?
|
||||
@@ -85,7 +86,7 @@ pub async fn export(
|
||||
.map(crate::models::oauth_clients::OAuthClient::from)
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let oauth_authorizations = crate::database::models::oauth_client_authorization_item::OAuthClientAuthorization::get_all_for_user(
|
||||
let oauth_authorizations = crate::database::models::oauth_client_authorization_item::DBOAuthClientAuthorization::get_all_for_user(
|
||||
user_id, &**pool,
|
||||
)
|
||||
.await?
|
||||
@@ -94,12 +95,12 @@ pub async fn export(
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let pat_ids =
|
||||
crate::database::models::pat_item::PersonalAccessToken::get_user_pats(
|
||||
crate::database::models::pat_item::DBPersonalAccessToken::get_user_pats(
|
||||
user_id, &**pool, &redis,
|
||||
)
|
||||
.await?;
|
||||
let pats =
|
||||
crate::database::models::pat_item::PersonalAccessToken::get_many_ids(
|
||||
crate::database::models::pat_item::DBPersonalAccessToken::get_many_ids(
|
||||
&pat_ids, &**pool, &redis,
|
||||
)
|
||||
.await?
|
||||
@@ -108,12 +109,12 @@ pub async fn export(
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let payout_ids =
|
||||
crate::database::models::payout_item::Payout::get_all_for_user(
|
||||
crate::database::models::payout_item::DBPayout::get_all_for_user(
|
||||
user_id, &**pool,
|
||||
)
|
||||
.await?;
|
||||
|
||||
let payouts = crate::database::models::payout_item::Payout::get_many(
|
||||
let payouts = crate::database::models::payout_item::DBPayout::get_many(
|
||||
&payout_ids,
|
||||
&**pool,
|
||||
)
|
||||
@@ -122,10 +123,11 @@ pub async fn export(
|
||||
.map(crate::models::payouts::Payout::from)
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let report_ids =
|
||||
crate::database::models::user_item::User::get_reports(user_id, &**pool)
|
||||
.await?;
|
||||
let reports = crate::database::models::report_item::Report::get_many(
|
||||
let report_ids = crate::database::models::user_item::DBUser::get_reports(
|
||||
user_id, &**pool,
|
||||
)
|
||||
.await?;
|
||||
let reports = crate::database::models::report_item::DBReport::get_many(
|
||||
&report_ids,
|
||||
&**pool,
|
||||
)
|
||||
@@ -147,7 +149,7 @@ pub async fn export(
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let messages =
|
||||
crate::database::models::thread_item::ThreadMessage::get_many(
|
||||
crate::database::models::thread_item::DBThreadMessage::get_many(
|
||||
&message_ids,
|
||||
&**pool,
|
||||
)
|
||||
@@ -166,18 +168,19 @@ pub async fn export(
|
||||
.map(|x| crate::database::models::ids::DBImageId(x.id))
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let uploaded_images = crate::database::models::image_item::Image::get_many(
|
||||
&uploaded_images_ids,
|
||||
&**pool,
|
||||
&redis,
|
||||
)
|
||||
.await?
|
||||
.into_iter()
|
||||
.map(crate::models::images::Image::from)
|
||||
.collect::<Vec<_>>();
|
||||
let uploaded_images =
|
||||
crate::database::models::image_item::DBImage::get_many(
|
||||
&uploaded_images_ids,
|
||||
&**pool,
|
||||
&redis,
|
||||
)
|
||||
.await?
|
||||
.into_iter()
|
||||
.map(crate::models::images::Image::from)
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let subscriptions =
|
||||
crate::database::models::user_subscription_item::UserSubscriptionItem::get_all_user(
|
||||
crate::database::models::user_subscription_item::DBUserSubscription::get_all_user(
|
||||
user_id, &**pool,
|
||||
)
|
||||
.await?
|
||||
|
||||
@@ -61,7 +61,7 @@ pub async fn get_projects(
|
||||
.await?;
|
||||
|
||||
let projects: Vec<_> =
|
||||
database::Project::get_many_ids(&project_ids, &**pool, &redis)
|
||||
database::DBProject::get_many_ids(&project_ids, &**pool, &redis)
|
||||
.await?
|
||||
.into_iter()
|
||||
.map(crate::models::projects::Project::from)
|
||||
@@ -88,7 +88,7 @@ pub async fn get_project_meta(
|
||||
|
||||
let project_id = info.into_inner().0;
|
||||
let project =
|
||||
database::models::Project::get(&project_id, &**pool, &redis).await?;
|
||||
database::models::DBProject::get(&project_id, &**pool, &redis).await?;
|
||||
|
||||
if let Some(project) = project {
|
||||
let rows = sqlx::query!(
|
||||
|
||||
@@ -45,13 +45,13 @@ pub async fn get_pats(
|
||||
.1;
|
||||
|
||||
let pat_ids =
|
||||
database::models::pat_item::PersonalAccessToken::get_user_pats(
|
||||
database::models::pat_item::DBPersonalAccessToken::get_user_pats(
|
||||
user.id.into(),
|
||||
&**pool,
|
||||
&redis,
|
||||
)
|
||||
.await?;
|
||||
let pats = database::models::pat_item::PersonalAccessToken::get_many_ids(
|
||||
let pats = database::models::pat_item::DBPersonalAccessToken::get_many_ids(
|
||||
&pat_ids, &**pool, &redis,
|
||||
)
|
||||
.await?;
|
||||
@@ -116,7 +116,7 @@ pub async fn create_pat(
|
||||
let token = format!("mrp_{token}");
|
||||
|
||||
let name = info.name.clone();
|
||||
database::models::pat_item::PersonalAccessToken {
|
||||
database::models::pat_item::DBPersonalAccessToken {
|
||||
id,
|
||||
name: name.clone(),
|
||||
access_token: token.clone(),
|
||||
@@ -130,7 +130,7 @@ pub async fn create_pat(
|
||||
.await?;
|
||||
|
||||
transaction.commit().await?;
|
||||
database::models::pat_item::PersonalAccessToken::clear_cache(
|
||||
database::models::pat_item::DBPersonalAccessToken::clear_cache(
|
||||
vec![(None, None, Some(user.id.into()))],
|
||||
&redis,
|
||||
)
|
||||
@@ -180,7 +180,7 @@ pub async fn edit_pat(
|
||||
.1;
|
||||
|
||||
let id = id.into_inner().0;
|
||||
let pat = database::models::pat_item::PersonalAccessToken::get(
|
||||
let pat = database::models::pat_item::DBPersonalAccessToken::get(
|
||||
&id, &**pool, &redis,
|
||||
)
|
||||
.await?;
|
||||
@@ -242,7 +242,7 @@ pub async fn edit_pat(
|
||||
}
|
||||
|
||||
transaction.commit().await?;
|
||||
database::models::pat_item::PersonalAccessToken::clear_cache(
|
||||
database::models::pat_item::DBPersonalAccessToken::clear_cache(
|
||||
vec![(Some(pat.id), Some(pat.access_token), Some(pat.user_id))],
|
||||
&redis,
|
||||
)
|
||||
@@ -271,7 +271,7 @@ pub async fn delete_pat(
|
||||
.await?
|
||||
.1;
|
||||
let id = id.into_inner().0;
|
||||
let pat = database::models::pat_item::PersonalAccessToken::get(
|
||||
let pat = database::models::pat_item::DBPersonalAccessToken::get(
|
||||
&id, &**pool, &redis,
|
||||
)
|
||||
.await?;
|
||||
@@ -279,13 +279,13 @@ pub async fn delete_pat(
|
||||
if let Some(pat) = pat {
|
||||
if pat.user_id == user.id.into() {
|
||||
let mut transaction = pool.begin().await?;
|
||||
database::models::pat_item::PersonalAccessToken::remove(
|
||||
database::models::pat_item::DBPersonalAccessToken::remove(
|
||||
pat.id,
|
||||
&mut transaction,
|
||||
)
|
||||
.await?;
|
||||
transaction.commit().await?;
|
||||
database::models::pat_item::PersonalAccessToken::clear_cache(
|
||||
database::models::pat_item::DBPersonalAccessToken::clear_cache(
|
||||
vec![(Some(pat.id), Some(pat.access_token), Some(pat.user_id))],
|
||||
&redis,
|
||||
)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use crate::auth::{AuthenticationError, get_user_from_headers};
|
||||
use crate::database::models::DBUserId;
|
||||
use crate::database::models::session_item::Session as DBSession;
|
||||
use crate::database::models::session_item::DBSession;
|
||||
use crate::database::models::session_item::SessionBuilder;
|
||||
use crate::database::redis::RedisPool;
|
||||
use crate::models::pats::Scopes;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use crate::auth::AuthenticationError;
|
||||
use crate::auth::validate::get_user_record_from_bearer_token;
|
||||
use crate::database::models::friend_item::FriendItem;
|
||||
use crate::database::models::friend_item::DBFriend;
|
||||
use crate::database::redis::RedisPool;
|
||||
use crate::models::pats::Scopes;
|
||||
use crate::models::users::User;
|
||||
@@ -85,8 +85,7 @@ pub async fn ws_init(
|
||||
};
|
||||
|
||||
let friends =
|
||||
FriendItem::get_user_friends(user.id.into(), Some(true), &**pool)
|
||||
.await?;
|
||||
DBFriend::get_user_friends(user.id.into(), Some(true), &**pool).await?;
|
||||
|
||||
let friend_statuses = if !friends.is_empty() {
|
||||
let db = db.clone();
|
||||
@@ -383,7 +382,7 @@ pub async fn broadcast_to_local_friends(
|
||||
user_id,
|
||||
message,
|
||||
sockets,
|
||||
FriendItem::get_user_friends(user_id.into(), Some(true), pool).await?,
|
||||
DBFriend::get_user_friends(user_id.into(), Some(true), pool).await?,
|
||||
)
|
||||
.await
|
||||
}
|
||||
@@ -392,7 +391,7 @@ async fn broadcast_to_known_local_friends(
|
||||
user_id: UserId,
|
||||
message: ServerToClientMessage,
|
||||
sockets: &ActiveSockets,
|
||||
friends: Vec<FriendItem>,
|
||||
friends: Vec<DBFriend>,
|
||||
) -> Result<(), crate::database::models::DatabaseError> {
|
||||
// FIXME Probably shouldn't be using database errors for this. Maybe ApiError?
|
||||
|
||||
|
||||
Reference in New Issue
Block a user