diff --git a/crates/app/src/routes/api/v1/products.rs b/crates/app/src/routes/api/v1/products.rs index 03e319c..c9eef1a 100644 --- a/crates/app/src/routes/api/v1/products.rs +++ b/crates/app/src/routes/api/v1/products.rs @@ -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,