add: infinite post drafts for supporters

This commit is contained in:
trisua 2025-05-17 20:02:55 -04:00
parent f6cbeb9bd8
commit abc597de95
4 changed files with 21 additions and 3 deletions

View file

@ -333,7 +333,8 @@
</div> </div>
<div class="card flex flex-col gap-2"> <div class="card flex flex-col gap-2">
{% for draft in drafts %} {{ components::supporter_ad(body="Become a supporter to save
infinite post drafts!") }} {% for draft in drafts %}
<div class="card-nest"> <div class="card-nest">
<div class="card small flex flex-col gap-2"> <div class="card small flex flex-col gap-2">
<span class="no_p_margin" <span class="no_p_margin"

View file

@ -537,6 +537,7 @@
<li>Ability to upload and use gif emojis</li> <li>Ability to upload and use gif emojis</li>
<li>Create infinite stack timelines</li> <li>Create infinite stack timelines</li>
<li>Ability to upload images to posts</li> <li>Ability to upload images to posts</li>
<li>Save infinite post drafts</li>
</ul> </ul>
<a <a

View file

@ -83,6 +83,8 @@ impl DataManager {
Ok(res.unwrap()) Ok(res.unwrap())
} }
const MAXIMUM_FREE_DRAFTS: usize = 10;
/// Create a new post draft in the database. /// Create a new post draft in the database.
/// ///
/// # Arguments /// # Arguments
@ -95,6 +97,19 @@ impl DataManager {
return Err(Error::DataTooLong("content".to_string())); return Err(Error::DataTooLong("content".to_string()));
} }
// check number of stacks
let owner = self.get_user_by_id(data.owner).await?;
if !owner.permissions.check(FinePermission::SUPPORTER) {
let stacks = self.get_stacks_by_owner(data.owner).await?;
if stacks.len() >= Self::MAXIMUM_FREE_DRAFTS {
return Err(Error::MiscError(
"You already have the maximum number of drafts you can have".to_string(),
));
}
}
// ... // ...
let conn = match self.connect().await { let conn = match self.connect().await {
Ok(c) => c, Ok(c) => c,

View file

@ -117,6 +117,8 @@ impl DataManager {
Ok(res.unwrap()) Ok(res.unwrap())
} }
const MAXIMUM_FREE_STACKS: usize = 5;
/// Create a new stack in the database. /// Create a new stack in the database.
/// ///
/// # Arguments /// # Arguments
@ -134,9 +136,8 @@ impl DataManager {
if !owner.permissions.check(FinePermission::SUPPORTER) { if !owner.permissions.check(FinePermission::SUPPORTER) {
let stacks = self.get_stacks_by_owner(data.owner).await?; let stacks = self.get_stacks_by_owner(data.owner).await?;
let maximum_count = 5;
if stacks.len() >= maximum_count { if stacks.len() >= Self::MAXIMUM_FREE_STACKS {
return Err(Error::MiscError( return Err(Error::MiscError(
"You already have the maximum number of stacks you can have".to_string(), "You already have the maximum number of stacks you can have".to_string(),
)); ));