add: don't allow free ProfileStyle products
This commit is contained in:
parent
7f0cb1f2a1
commit
59378a4447
1 changed files with 20 additions and 1 deletions
|
@ -213,7 +213,14 @@ pub async fn update_price_request(
|
|||
None => return Json(Error::NotAllowed.into()),
|
||||
};
|
||||
|
||||
if req.price < 25 && req.price != 0 {
|
||||
let product = match data.get_product_by_id(id).await {
|
||||
Ok(x) => x,
|
||||
Err(e) => return Json(e.into()),
|
||||
};
|
||||
|
||||
let can_be_free = product.method != ProductFulfillmentMethod::ProfileStyle;
|
||||
|
||||
if req.price < 25 && (!can_be_free || req.price != 0) {
|
||||
return Json(
|
||||
Error::MiscError(
|
||||
"Price is too low, please use a price of 25 coins or more".to_string(),
|
||||
|
@ -250,6 +257,18 @@ pub async fn update_method_request(
|
|||
return Json(Error::RequiresSupporter.into());
|
||||
}
|
||||
|
||||
let product = match data.get_product_by_id(id).await {
|
||||
Ok(x) => x,
|
||||
Err(e) => return Json(e.into()),
|
||||
};
|
||||
|
||||
if req.method == ProductFulfillmentMethod::ProfileStyle && product.price == 0 {
|
||||
// no free profile styles
|
||||
if let Err(e) = data.update_product_price(id, &user, 25).await {
|
||||
return Json(e.into());
|
||||
}
|
||||
}
|
||||
|
||||
match data.update_product_method(id, &user, req.method).await {
|
||||
Ok(_) => Json(ApiReturn {
|
||||
ok: true,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue