diff --git a/crates/app/src/public/html/profile/settings.lisp b/crates/app/src/public/html/profile/settings.lisp
index d317d95..33f6117 100644
--- a/crates/app/src/public/html/profile/settings.lisp
+++ b/crates/app/src/public/html/profile/settings.lisp
@@ -579,7 +579,9 @@
(li
(text "Ability to create forges"))
(li
- (text "Ability to create more than 1 app")))
+ (text "Ability to create more than 1 app"))
+ (li
+ (text "Create up to 10 stack blocks")))
(a
("href" "{{ config.stripe.payment_link }}?client_reference_id={{ user.id }}")
("class" "button")
diff --git a/crates/core/src/database/stackblocks.rs b/crates/core/src/database/stackblocks.rs
index 0ae9e82..8d2d633 100644
--- a/crates/core/src/database/stackblocks.rs
+++ b/crates/core/src/database/stackblocks.rs
@@ -112,12 +112,34 @@ impl DataManager {
Ok(res.unwrap())
}
+ const MAXIMUM_FREE_STACKBLOCKS: usize = 5;
+ const MAXIMUM_SUPPORTER_STACKBLOCKS: usize = 10;
+
/// Create a new stack block in the database.
///
/// # Arguments
/// * `data` - a mock [`StackBlock`] object to insert
pub async fn create_stackblock(&self, data: StackBlock) -> Result<()> {
let initiator = self.get_user_by_id(data.initiator).await?;
+
+ // check number of stackblocks
+ let stackblocks = self.get_stackblocks_by_initiator(data.initiator).await;
+
+ if !initiator.permissions.check(FinePermission::SUPPORTER) {
+ if stackblocks.len() >= Self::MAXIMUM_FREE_STACKBLOCKS {
+ return Err(Error::MiscError(
+ "You already have the maximum number of stack blocks you can have".to_string(),
+ ));
+ }
+ } else {
+ if stackblocks.len() >= Self::MAXIMUM_SUPPORTER_STACKBLOCKS {
+ return Err(Error::MiscError(
+ "You already have the maximum number of stack blocks you can have".to_string(),
+ ));
+ }
+ }
+
+ // ...
let stack = self.get_stack_by_id(data.stack).await?;
if initiator.id != stack.owner