You've already forked AstralRinth
forked from didirus/AstralRinth
Switch to Trolley for Modrinth Payments (#727)
* most of trolley * Switch to trolley for payments * run prepare * fix clippy * fix more * Fix most tests + bitflags * Update src/auth/flows.rs Co-authored-by: Jackson Kruger <jak.kruger@gmail.com> * Finish trolley * run prep for merge * Update src/queue/payouts.rs Co-authored-by: Jackson Kruger <jak.kruger@gmail.com> --------- Co-authored-by: Jackson Kruger <jak.kruger@gmail.com>
This commit is contained in:
@@ -210,7 +210,7 @@ impl Collection {
|
||||
color: m.color.map(|x| x as u32),
|
||||
created: m.created,
|
||||
updated: m.updated,
|
||||
status: CollectionStatus::from_str(&m.status),
|
||||
status: CollectionStatus::from_string(&m.status),
|
||||
projects: m
|
||||
.mods
|
||||
.unwrap_or_default()
|
||||
|
||||
@@ -630,10 +630,10 @@ impl Project {
|
||||
license_url: m.license_url.clone(),
|
||||
discord_url: m.discord_url.clone(),
|
||||
client_side: SideTypeId(m.client_side),
|
||||
status: ProjectStatus::from_str(
|
||||
status: ProjectStatus::from_string(
|
||||
&m.status,
|
||||
),
|
||||
requested_status: m.requested_status.map(|x| ProjectStatus::from_str(
|
||||
requested_status: m.requested_status.map(|x| ProjectStatus::from_string(
|
||||
&x,
|
||||
)),
|
||||
server_side: SideTypeId(m.server_side),
|
||||
@@ -647,7 +647,7 @@ impl Project {
|
||||
webhook_sent: m.webhook_sent,
|
||||
color: m.color.map(|x| x as u32),
|
||||
queued: m.queued,
|
||||
monetization_status: MonetizationStatus::from_str(
|
||||
monetization_status: MonetizationStatus::from_string(
|
||||
&m.monetization_status,
|
||||
),
|
||||
loaders: m.loaders,
|
||||
@@ -685,8 +685,8 @@ impl Project {
|
||||
donation_urls: serde_json::from_value(
|
||||
m.donations.unwrap_or_default(),
|
||||
).ok().unwrap_or_default(),
|
||||
client_side: crate::models::projects::SideType::from_str(&m.client_side_type),
|
||||
server_side: crate::models::projects::SideType::from_str(&m.server_side_type),
|
||||
client_side: crate::models::projects::SideType::from_string(&m.client_side_type),
|
||||
server_side: crate::models::projects::SideType::from_string(&m.server_side_type),
|
||||
thread_id: ThreadId(m.thread_id),
|
||||
}}))
|
||||
})
|
||||
|
||||
@@ -148,7 +148,7 @@ impl Thread {
|
||||
id: ThreadId(x.id),
|
||||
project_id: x.mod_id.map(ProjectId),
|
||||
report_id: x.report_id.map(ReportId),
|
||||
type_: ThreadType::from_str(&x.thread_type),
|
||||
type_: ThreadType::from_string(&x.thread_type),
|
||||
messages: {
|
||||
let mut messages: Vec<ThreadMessage> = serde_json::from_value(
|
||||
x.messages.unwrap_or_default(),
|
||||
|
||||
@@ -3,7 +3,7 @@ use super::CollectionId;
|
||||
use crate::database::models::DatabaseError;
|
||||
use crate::database::redis::RedisPool;
|
||||
use crate::models::ids::base62_impl::{parse_base62, to_base62};
|
||||
use crate::models::users::{Badges, RecipientType, RecipientWallet};
|
||||
use crate::models::users::{Badges, RecipientStatus};
|
||||
use chrono::{DateTime, Utc};
|
||||
use rust_decimal::Decimal;
|
||||
use serde::{Deserialize, Serialize};
|
||||
@@ -35,10 +35,10 @@ pub struct User {
|
||||
pub created: DateTime<Utc>,
|
||||
pub role: String,
|
||||
pub badges: Badges,
|
||||
|
||||
pub balance: Decimal,
|
||||
pub payout_wallet: Option<RecipientWallet>,
|
||||
pub payout_wallet_type: Option<RecipientType>,
|
||||
pub payout_address: Option<String>,
|
||||
pub trolley_id: Option<String>,
|
||||
pub trolley_account_status: Option<RecipientStatus>,
|
||||
}
|
||||
|
||||
impl User {
|
||||
@@ -188,9 +188,9 @@ impl User {
|
||||
SELECT id, name, email,
|
||||
avatar_url, username, bio,
|
||||
created, role, badges,
|
||||
balance, payout_wallet, payout_wallet_type, payout_address,
|
||||
balance,
|
||||
github_id, discord_id, gitlab_id, google_id, steam_id, microsoft_id,
|
||||
email_verified, password, totp_secret
|
||||
email_verified, password, totp_secret, trolley_id, trolley_account_status
|
||||
FROM users
|
||||
WHERE id = ANY($1) OR LOWER(username) = ANY($2)
|
||||
",
|
||||
@@ -220,13 +220,13 @@ impl User {
|
||||
role: u.role,
|
||||
badges: Badges::from_bits(u.badges as u64).unwrap_or_default(),
|
||||
balance: u.balance,
|
||||
payout_wallet: u.payout_wallet.map(|x| RecipientWallet::from_string(&x)),
|
||||
payout_wallet_type: u
|
||||
.payout_wallet_type
|
||||
.map(|x| RecipientType::from_string(&x)),
|
||||
payout_address: u.payout_address,
|
||||
password: u.password,
|
||||
totp_secret: u.totp_secret,
|
||||
trolley_id: u.trolley_id,
|
||||
trolley_account_status: u
|
||||
.trolley_account_status
|
||||
.as_ref()
|
||||
.map(|x| RecipientStatus::from_string(x)),
|
||||
}))
|
||||
})
|
||||
.try_collect::<Vec<User>>()
|
||||
@@ -352,7 +352,7 @@ impl User {
|
||||
redis: &RedisPool,
|
||||
) -> Result<(), DatabaseError> {
|
||||
redis
|
||||
.delete_many(user_ids.into_iter().flat_map(|(id, username)| {
|
||||
.delete_many(user_ids.iter().flat_map(|(id, username)| {
|
||||
[
|
||||
(USERS_NAMESPACE, Some(id.0.to_string())),
|
||||
(
|
||||
|
||||
@@ -590,9 +590,9 @@ impl Version {
|
||||
downloads: v.downloads,
|
||||
version_type: v.version_type,
|
||||
featured: v.featured,
|
||||
status: VersionStatus::from_str(&v.status),
|
||||
status: VersionStatus::from_string(&v.status),
|
||||
requested_status: v.requested_status
|
||||
.map(|x| VersionStatus::from_str(&x)),
|
||||
.map(|x| VersionStatus::from_string(&x)),
|
||||
},
|
||||
files: {
|
||||
#[derive(Deserialize)]
|
||||
@@ -803,7 +803,7 @@ impl Version {
|
||||
.unwrap_or_default().into_iter().map(|x| (x.algorithm, x.hash)).collect(),
|
||||
primary: f.is_primary,
|
||||
size: f.size as u32,
|
||||
file_type: f.file_type.map(|x| FileType::from_str(&x)),
|
||||
file_type: f.file_type.map(|x| FileType::from_string(&x)),
|
||||
}
|
||||
}
|
||||
))
|
||||
|
||||
Reference in New Issue
Block a user