add: 8 more achievements
This commit is contained in:
parent
8d70f65863
commit
a799c777ea
11 changed files with 121 additions and 18 deletions
|
@ -713,6 +713,10 @@ impl DataManager {
|
|||
///
|
||||
/// Still returns `Ok` if the user already has the achievement.
|
||||
pub async fn add_achievement(&self, user: &mut User, achievement: Achievement) -> Result<()> {
|
||||
if user.settings.disable_achievements {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
if user
|
||||
.achievements
|
||||
.iter()
|
||||
|
|
|
@ -299,11 +299,10 @@ impl DataManager {
|
|||
}
|
||||
|
||||
// add community owner as admin
|
||||
self.create_membership(CommunityMembership::new(
|
||||
data.owner,
|
||||
data.id,
|
||||
CommunityPermission::ADMINISTRATOR,
|
||||
))
|
||||
self.create_membership(
|
||||
CommunityMembership::new(data.owner, data.id, CommunityPermission::ADMINISTRATOR),
|
||||
&owner,
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use oiseau::cache::Cache;
|
||||
use crate::model::auth::AchievementName;
|
||||
use crate::model::communities::Community;
|
||||
use crate::model::requests::{ActionRequest, ActionType};
|
||||
use crate::model::{
|
||||
|
@ -169,7 +170,11 @@ impl DataManager {
|
|||
/// # Arguments
|
||||
/// * `data` - a mock [`CommunityMembership`] object to insert
|
||||
#[async_recursion::async_recursion]
|
||||
pub async fn create_membership(&self, data: CommunityMembership) -> Result<String> {
|
||||
pub async fn create_membership(
|
||||
&self,
|
||||
data: CommunityMembership,
|
||||
user: &User,
|
||||
) -> Result<String> {
|
||||
// make sure membership doesn't already exist
|
||||
if self
|
||||
.get_membership_by_owner_community_no_void(data.owner, data.community)
|
||||
|
@ -199,7 +204,7 @@ impl DataManager {
|
|||
.await?;
|
||||
|
||||
// ...
|
||||
return self.create_membership(data).await;
|
||||
return self.create_membership(data, user).await;
|
||||
}
|
||||
}
|
||||
_ => (),
|
||||
|
@ -237,6 +242,9 @@ impl DataManager {
|
|||
Ok(if data.role.check(CommunityPermission::REQUESTED) {
|
||||
"Join request sent".to_string()
|
||||
} else {
|
||||
self.add_achievement(&mut user.clone(), AchievementName::JoinCommunity.into())
|
||||
.await?;
|
||||
|
||||
"Community joined".to_string()
|
||||
})
|
||||
}
|
||||
|
|
|
@ -265,6 +265,33 @@ impl DataManager {
|
|||
self.add_achievement(&mut other_user, AchievementName::FollowedByStaff.into())
|
||||
.await?;
|
||||
}
|
||||
|
||||
// other achivements
|
||||
self.add_achievement(&mut other_user, AchievementName::Get1Follower.into())
|
||||
.await?;
|
||||
|
||||
if other_user.follower_count >= 9 {
|
||||
self.add_achievement(&mut other_user, AchievementName::Get10Followers.into())
|
||||
.await?;
|
||||
}
|
||||
|
||||
if other_user.follower_count >= 49 {
|
||||
self.add_achievement(&mut other_user, AchievementName::Get50Followers.into())
|
||||
.await?;
|
||||
}
|
||||
|
||||
if other_user.follower_count >= 99 {
|
||||
self.add_achievement(&mut other_user, AchievementName::Get100Followers.into())
|
||||
.await?;
|
||||
}
|
||||
|
||||
if initiator.following_count >= 9 {
|
||||
self.add_achievement(
|
||||
&mut initiator.clone(),
|
||||
AchievementName::Follow10Users.into(),
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
}
|
||||
|
||||
// ...
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue