add: automatically stop all user ads when user cannot afford transfer

This commit is contained in:
trisua 2025-08-11 20:44:16 -04:00
parent 2cb7d08ddc
commit 59bccd9474
4 changed files with 70 additions and 26 deletions

View file

@ -17,7 +17,7 @@ use tetratto_core::model::{
};
use super::{CreateAd, UpdateAdIsRunning};
const MAXIMUM_AD_FILE_SIZE: usize = 4_194_304;
const MAXIMUM_AD_FILE_SIZE: usize = 2_097_152;
pub async fn create_request(
jar: CookieJar,
@ -104,6 +104,15 @@ pub async fn update_is_running_request(
None => return Json(Error::NotAllowed.into()),
};
if user.coins < 50 {
return Json(
Error::MiscError(
"You must have a minimum of 50 coins in your balance to run ads".to_string(),
)
.into(),
);
}
match data
.update_ad_is_running(id, &user, if req.is_running { 1 } else { 0 })
.await