add: infinite post drafts for supporters
This commit is contained in:
parent
f6cbeb9bd8
commit
abc597de95
4 changed files with 21 additions and 3 deletions
|
@ -333,7 +333,8 @@
|
|||
</div>
|
||||
|
||||
<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 small flex flex-col gap-2">
|
||||
<span class="no_p_margin"
|
||||
|
|
|
@ -537,6 +537,7 @@
|
|||
<li>Ability to upload and use gif emojis</li>
|
||||
<li>Create infinite stack timelines</li>
|
||||
<li>Ability to upload images to posts</li>
|
||||
<li>Save infinite post drafts</li>
|
||||
</ul>
|
||||
|
||||
<a
|
||||
|
|
|
@ -83,6 +83,8 @@ impl DataManager {
|
|||
Ok(res.unwrap())
|
||||
}
|
||||
|
||||
const MAXIMUM_FREE_DRAFTS: usize = 10;
|
||||
|
||||
/// Create a new post draft in the database.
|
||||
///
|
||||
/// # Arguments
|
||||
|
@ -95,6 +97,19 @@ impl DataManager {
|
|||
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 {
|
||||
Ok(c) => c,
|
||||
|
|
|
@ -117,6 +117,8 @@ impl DataManager {
|
|||
Ok(res.unwrap())
|
||||
}
|
||||
|
||||
const MAXIMUM_FREE_STACKS: usize = 5;
|
||||
|
||||
/// Create a new stack in the database.
|
||||
///
|
||||
/// # Arguments
|
||||
|
@ -134,9 +136,8 @@ impl DataManager {
|
|||
|
||||
if !owner.permissions.check(FinePermission::SUPPORTER) {
|
||||
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(
|
||||
"You already have the maximum number of stacks you can have".to_string(),
|
||||
));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue