add: 4 more achievements

This commit is contained in:
trisua 2025-06-29 18:38:32 -04:00
parent 50f4592de2
commit b501a7c5f0
5 changed files with 52 additions and 7 deletions

View file

@ -1,6 +1,6 @@
use std::collections::HashMap;
use crate::config::StringBan;
use crate::model::auth::Notification;
use crate::model::auth::{AchievementName, Notification};
use crate::model::communities::{CommunityMembership, CommunityReadAccess, Poll, Question};
use crate::model::communities_permissions::CommunityPermission;
use crate::model::moderation::AuditLogEntry;
@ -1624,6 +1624,8 @@ impl DataManager {
self.get_community_by_id(data.community).await?
};
let mut owner = self.get_user_by_id(data.owner).await?;
// check values (if this isn't reposting something else)
let is_reposting = if let Some(ref repost) = data.context.repost {
repost.reposting.is_some()
@ -1651,6 +1653,10 @@ impl DataManager {
} else if data.title.len() > 128 {
return Err(Error::DataTooLong("title".to_string()));
}
// award achievement
self.add_achievement(&mut owner, AchievementName::CreatePostWithTitle.into())
.await?;
}
}
@ -1663,7 +1669,6 @@ impl DataManager {
data.context.is_nsfw = community.context.is_nsfw;
// remove request if we were answering a question
let owner = self.get_user_by_id(data.owner).await?;
if data.context.answering != 0 {
let question = self.get_question_by_id(data.context.answering).await?;
@ -1790,6 +1795,10 @@ impl DataManager {
)
.await?;
}
// award achievement
self.add_achievement(&mut owner, AchievementName::CreateRepost.into())
.await?;
}
// check if the post we're replying to allows commments