You've already forked AstralRinth
forked from didirus/AstralRinth
Payouts finish (#470)
* Almost done * More work on midas * Finish payouts backend * Update Cargo.lock * Run fmt + prepare
This commit is contained in:
@@ -73,6 +73,7 @@ where
|
||||
created: result.created,
|
||||
role: Role::from_string(&result.role),
|
||||
badges: result.badges,
|
||||
paypal_email: result.paypal_email,
|
||||
}),
|
||||
None => Err(AuthenticationError::InvalidCredentials),
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ pub mod auth;
|
||||
pub mod env;
|
||||
pub mod ext;
|
||||
pub mod guards;
|
||||
pub mod payout_calc;
|
||||
pub mod routes;
|
||||
pub mod validate;
|
||||
pub mod webhook;
|
||||
|
||||
22
src/util/payout_calc.rs
Normal file
22
src/util/payout_calc.rs
Normal file
@@ -0,0 +1,22 @@
|
||||
use chrono::{DateTime, Datelike, NaiveDate, NaiveDateTime, NaiveTime, Utc};
|
||||
|
||||
pub fn get_claimable_time(
|
||||
current: DateTime<Utc>,
|
||||
future: bool,
|
||||
) -> DateTime<Utc> {
|
||||
let adder = if current.month() == 1 && !future {
|
||||
(-1, 12)
|
||||
} else if current.month() == 12 && future {
|
||||
(1, 1)
|
||||
} else {
|
||||
(0, current.month())
|
||||
};
|
||||
|
||||
DateTime::from_utc(
|
||||
NaiveDateTime::new(
|
||||
NaiveDate::from_ymd(current.year() + adder.0, adder.1, 16),
|
||||
NaiveTime::default(),
|
||||
),
|
||||
Utc,
|
||||
)
|
||||
}
|
||||
@@ -89,7 +89,7 @@ pub fn validate_deps(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn validate_url(value: &String) -> Result<(), validator::ValidationError> {
|
||||
pub fn validate_url(value: &str) -> Result<(), validator::ValidationError> {
|
||||
let url = url::Url::parse(value)
|
||||
.ok()
|
||||
.ok_or_else(|| validator::ValidationError::new("invalid URL"))?;
|
||||
|
||||
Reference in New Issue
Block a user