add upper bound to sanctuary update time
This commit is contained in:
parent
65849ab8bd
commit
ae2c32e5ca
1 changed files with 10 additions and 0 deletions
|
@ -1,3 +1,5 @@
|
|||
use chrono::{Duration, Utc};
|
||||
|
||||
use crate::types::Population;
|
||||
|
||||
pub async fn saerro(world: i32) -> Result<Population, ()> {
|
||||
|
@ -190,6 +192,7 @@ pub async fn sanctuary(world: i32) -> Result<Population, ()> {
|
|||
#[derive(serde::Deserialize)]
|
||||
struct World {
|
||||
pub population: SanctuaryPopulation,
|
||||
pub timestamp: i64,
|
||||
}
|
||||
|
||||
#[derive(serde::Deserialize)]
|
||||
|
@ -215,6 +218,13 @@ pub async fn sanctuary(world: i32) -> Result<Population, ()> {
|
|||
.await
|
||||
.unwrap();
|
||||
|
||||
// error if over 15 minutes old
|
||||
if response.world_population_list[0].timestamp
|
||||
< (Utc::now() - Duration::minutes(15)).timestamp()
|
||||
{
|
||||
return Err(());
|
||||
}
|
||||
|
||||
Ok(Population {
|
||||
nc: response.world_population_list[0].population.nc,
|
||||
tr: response.world_population_list[0].population.tr,
|
||||
|
|
Loading…
Add table
Reference in a new issue